George 的个人资料George's XNA Programming日志列表网络 工具 帮助

日志


3月3日

XNA Slots - Part 1

While looking at my blog's statistics, I noticed that I get many visitors searching for slot game implemented in XNA. I decided to dedicate a number of posts to building a simple slot game in Microsoft XNA. I will start from a very simple demo game and ultimately grow the project to a full-featured slot game.

We will be developing a multi-line video slots game. More specifically, our slot game will have 5 columns and 3 visible lines as shown on the game screen-shot.

In this type of slots, there are 9 playing lines and a user can choose which lines he/she wants to play.

The heart of the game is a class, which I have named Reel. This class is in charge of rendering and animating the slot symbols on the screen.

In the image on the left, you can see the texture that we will be using for our slot game. The actual texture is a 800 x 1920 pixel image, which contains 12 rows and 5 columns. Each column corresponds to a single reel and each row corresponds to a stop or position (i.e. the symbol) on the reel. The texture width and height are multiples of 4 and thus we can use the XNA compression to reduce the file size of the texture. The nice looking symbols are taken from Microsoft's Office Clips Online web site.

Our reel will be using a virtual stop table. I will be describing the virtual table in an upcoming part but for now let's concentrate on the visual side of the game.

Each symbol corresponds to a stop on the reel. Let's agree that we call Stop 1 such a position of the reel when the lowest symbol on a column is located at the bottom line.

For example, if we take the first column, its Stop 1 corresponds to a position where the bottom 3 symbols (pineapple, coconut, berry) are visible on the screen. Stop 2 is when watermelon, pineapple and coconut are visible and so on. Thus, Stop 12 will be when the coconut, berry and cherry are visible on the screen. Please look at the illustration below to make sure that you have a correct understanding. 

You can download the source code and play with it. I have also put a compiled version for you to test. Run the application and hit the S key on the keyboard to spin.

Our Reel class is extremely flexible. If you wanted to make a single line slots game, all you had to do is to change the REEL_LINES constant value from 3 to 1.

In the next part we will add some labels on the screen so that we display different information (lines selected, balance, winnings) to the user.

Download the Source Code

Download Compiled Version

评论 (1)

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。

若要添加评论,请使用您的 Windows Live ID 登录(如果您使用过 Hotmail、Messenger 或 Xbox LIVE,您就拥有 Windows Live ID)。登录


还没有 Windows Live ID 吗?请注册

没有名字发表:
http://www.batteryfast.com/gateway/8msbg.htm gateway 8msbg battery ,
http://www.batteryfast.com/gateway/s62044l.htm gateway s62044l battery ,
http://www.batteryfast.com/gateway/m320.htm gateway m320 battery ,
http://www.batteryfast.com/gateway/m325.htm gateway m325 battery ,
http://www.batteryfast.com/gateway/4000.htm gateway 4000 battery ,
http://www.batteryfast.com/gateway/s62066l.htm gateway s62066l battery ,
http://www.batteryfast.com/gateway/m680.htm gateway m680 battery ,
http://www.batteryfast.com/gateway/m360.htm gateway m360 battery ,
http://www.batteryfast.com/gateway/m460.htm gateway m460 battery ,
http://www.batteryfast.com/gateway/s62066l.htm gateway s62066l battery ,
http://www.batteryfast.com/gateway/squ-412.htm gateway squ-412 battery ,
http://www.batteryfast.com/gateway/squ-413.htm gateway squ-413 battery ,
http://www.batteryfast.com/gateway/squ-414.htm gateway squ-414 battery ,
http://www.batteryfast.com/gateway/solo-1400.htm gateway solo 1400 battery ,
http://www.batteryfast.com/gateway/solo-1450.htm gateway solo 1450 battery ,
http://www.batteryfast.com/gateway/6500358.htm gateway 6500358 battery ,
http://www.batteryfast.com/gateway/gt-6300l.htm gateway gt-6300l battery ,
http://www.batteryfast.com/gateway/solo-9300.htm gateway solo 9300 battery ,
http://www.batteryfast.com/gateway/bat0016.htm gateway bat0016 battery ,
http://www.batteryfast.com/gateway/m1200.htm gateway m1200 battery ,
http://www.batteryfast.com/gateway/m1300.htm gateway m1300 battery ,
http://www.batteryfast.com/gateway/m500.htm gateway m500 battery ,
http://www.batteryfast.com/gateway/m505.htm gateway m505 battery ,
http://www.batteryfast.com/gateway/btp-68b3.htm gateway btp-68b3 battery ,
http://www.batteryfast.com/gateway/btp-51b3.htm gateway btp-51b3 battery ,
http://www.batteryfast.com/hp/hstnn-db11.htm hp hstnn-db11 battery ,
http://www.batteryfast.com/hp/nc8230.htm hp nc8230 battery ,
http://www.batteryfast.com/hp/nc8200.htm hp nc8200 battery ,
http://www.batteryfast.com/hp/nw8200.htm hp nw8200 battery ,
http://www.batteryfast.com/hp/nx8200.htm hp nx8200 battery ,
http://www.batteryfast.com/hp/nc8430.htm hp nc8430 battery ,
http://www.batteryfast.com/hp/pb992a.htm hp pb992a battery ,
http://www.batteryfast.com/hp/nx7000.htm hp nx7000 battery ,
http://www.batteryfast.com/hp/presario-x1000.htm hp presario x1000 battery ,
http://www.batteryfast.com/hp/presario-x1100.htm hp presario x1100 battery ,
http://www.batteryfast.com/hp/presario-x1200.htm hp presario x1200 battery ,
http://www.batteryfast.com/hp/presario-x1300.htm hp presario x1300 battery ,
http://www.batteryfast.com/hp/presario-x1400.htm hp presario x1400 battery ,
http://www.batteryfast.com/hp/zt3000.htm hp zt3000 battery ,
http://www.batteryfast.com/hp/zt3100.htm hp zt3100 battery ,
http://www.batteryfast.com/hp/zt3200.htm hp zt3200 battery ,
http://www.batteryfast.com/hp/zt3300.htm hp zt3300 battery ,
http://www.batteryfast.com/hp/zt3400.htm hp zt3400 battery ,
http://www.batteryfast.com/hp/nx6120.htm hp nx6120 battery ,
3 月 9 日

引用通告 (8)

此日志的引用通告 URL 是:
http://xnadev.spaces.live.com/blog/cns!8B6E83562E8DE240!145.trak
引用此项的网络日志