Game Programming at scriptedfun » 1945 http://www.scriptedfun.com Game Programming for Beginners: Video Tutorials, Source Code, and Articles Thu, 11 Sep 2008 17:45:09 +0000 en hourly 1 http://wordpress.org/?v=3.3.1 http://creativecommons.org/licenses/by/2.5/ Shooting Mechanism Demo http://www.scriptedfun.com/shooting-mechanism-demo/ http://www.scriptedfun.com/shooting-mechanism-demo/#comments Mon, 11 Dec 2006 05:32:48 +0000 Chuck http://www.scriptedfun.com/shooting-mechanism-demo/ As a follow up to the background scrolling example, I’ve modified the 1945 code again to emphasize how the shooting mechanism works.

shooting mechanism example

Basically, the player is given two options for shooting:

  1. Every distinct click of the left mouse button guarantees one shot.
  2. Holding the left mouse button will make shots appear at regular intervals (rapid fire).

In a way, this gives the player the incentive to click if he wants a more rapid rate of fire, since you can effectively increase the intervals at which rapid fire gives off shots.

Feel free to ask questions! :)

shooting mechanism source code

]]>
http://www.scriptedfun.com/shooting-mechanism-demo/feed/ 2 http://creativecommons.org/licenses/by/2.5/
Pygame Scrolling Background http://www.scriptedfun.com/pygame-scrolling-background/ http://www.scriptedfun.com/pygame-scrolling-background/#comments Sat, 09 Dec 2006 13:52:12 +0000 Chuck http://www.scriptedfun.com/pygame-scrolling-background/ One of the questions that I’m asked most often is how the background scrolling in 1945 works. To answer this question, I’ve removed some of the code from the original 1945 code, added a few things, and came up with this scrolling demo:

scrolling background demo

The best way to understand how the scrolling actually works is by downloading the source code and experimenting with the program.

Here are the main changes:

  • The screen size is now 640 by 544 – the reason for this you will see when you run the code.
  • Scrolling is no longer automatic – you may use the up and down arrow keys to scroll the background. This should help you observe better what is going on.
  • The program ends by pressing Q – I’m hoping that this change would help the menu bar catch your attention…
  • A minimum of instructions is provided in the title bar.
  • Pressing the Escape key toggles between two ways of putting the background on the screen – this is the highlight of the code example.

Basically, we are taking advantage of the fact that the background is just a repeating pattern, so all we have to do is draw a background that is a little larger than the actual screen (here, the background is actually 640 by 512, but the screen size is 1945 is 640 by 480), then just move this large picture across the screen, creating the illusion of movement. Once we hit the edge, we just wrap the image around, which I think does a good job of making us believe that the sea just goes on and on and on to infinity.

If all that sounded complicated, I encourage you to try the demo and toggle between the two modes and scroll the background – you’ll see what I mean, and how simple it really is :)

Feel free to ask questions, and I hope you find this helpful!

scrolling background source code

]]>
http://www.scriptedfun.com/pygame-scrolling-background/feed/ 5 http://creativecommons.org/licenses/by/2.5/
1945 – a vertical scrolling shooter http://www.scriptedfun.com/1945-a-vertical-scrolling-shooter/ http://www.scriptedfun.com/1945-a-vertical-scrolling-shooter/#comments Sun, 02 Jul 2006 05:04:14 +0000 Chuck http://www.scriptedfun.com/?p=12 1945 is a clone of the popular vertical scrolling shooter 1942. Again, the graphics in the game were taken from the Spritelib by Ari Feldman. This game will serve as the basis for the screencasts once we finish Arinoid. The screencasts will probably begin with screencast 6. In the meantime, I am hoping that you’ll find the source code useful, and just leave a comment on the site if you have any questions :) . I posted this in advance because one of the site’s readers needed some help with animations, which this game has but Arinoid doesn’t. Aside from animations, this game also features a scrolling background.

1945 screenshot

In this game, enemy planes just appear randomly from the top of the screen, move downward, and try shoot you. You, in turn, should avoid the enemy planes and shoot them down using your semi-rapid-fire gun. Despite the simple mechanics, I think that the current prototype is already fun to play – there’s something satisfying about clearing the screen of things, accompanied by explosions; this is the basic premise of many arcade games.

The code I used for the animations is heavily based on the animation code in aliens.py, which is included in the Pygame source distribution. I highly encourage you to study the code for that game, because a lot of what I know about Pygame came from studying that code :) .

The 1945 code branches off from the barebones code, and borrows from Arinoid. However, in contrast to the barebones app which uses RenderUpdates, 1945 uses RenderPlain, because the entire screen changes at every frame due to the scrolling background, so dirty rectangles aren’t necessary.

The link to the 1945 zip file appears below. As usual, Python and Pygame are needed to run the program.

1945 source

]]>
http://www.scriptedfun.com/1945-a-vertical-scrolling-shooter/feed/ 8 http://creativecommons.org/licenses/by/2.5/
1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214| buying hydrochlorothiazide on line tablets buy trentaltricor and cost karela order online canada coumadin online pharmacy without a prescription buy generic trental no prescription cheapest bactrim pills bystolic buy online cheap buy generic hydrochlorothiazide xenical buy buy pills accutaneAccutane Online Doxycycline online Buy Cheap Lexapro Online No Prescription Prednisone Online Buy Accutane No Prescription