Presentation is loading. Please wait.

Presentation is loading. Please wait.

Games at Bolton Scrolling Andrew Williams adw1.

Similar presentations


Presentation on theme: "Games at Bolton Scrolling Andrew Williams adw1."— Presentation transcript:

1 Games at Bolton Scrolling Andrew Williams A.Williams@bolton.ac.uk http://www.bolton.ac.uk/staff/ adw1

2 Games at Bolton scrollh  The first example simply scrolls horizontally –Look at screenRect in the program –Read the comments in the program

3 Games at Bolton scrollv  This is the equivalent of scrollh, only with vertical scrolling –Obviously, it is scrolling the “wrong way” –Again, screenRect is the key

4 Games at Bolton scrollhsprite1  Adding a sprite to the example  Although it looks right, it’s actually wrong.  The sprite is in screen space and the background scrolls in world space

5 Games at Bolton scrollhsprite2  This time, although it looks wrong, it is actually correct! –Both background and sprite live in the same coordinate system

6 Games at Bolton scrollhsprite3  In this version, we move the sprite in an attempt to “keep up with” the background –But is this the right approach?

7 Games at Bolton scrollhsprite4  This is probably more correct: –The sprite moves in world space –We move the “viewport” on the background as the sprite moves

8 Games at Bolton scrollhsprite5  If we use this approach, we can place other sprites in world space and wait for our sprite to encounter them

9 Games at Bolton scrollhsprite6  Simple control of the player’s sprite –Notice particularly the new, more complex approach to keyboard control This fixes the problems we’ve been having with the PS2

10 Games at Bolton scrollhsprite7  This time there is no automatic movement of the player’s sprite –We move forward using the right-arrow key –Whether this is what you want is up to you

11 Games at Bolton scrollhsprite8  Random location of the enemies –Look out for srand(...) and rand() The s stands for “seed”


Download ppt "Games at Bolton Scrolling Andrew Williams adw1."

Similar presentations


Ads by Google