Download presentation
Presentation is loading. Please wait.
1
Copyright © 2002 Bolton Institute Scrolling Andrew Williams A.Williams@bolton.ac.uk http://www.bolton.ac.uk/staff/adw1
2
Copyright © 2002 Bolton Institute scrollh The first example simply scrolls horizontally –Look at screenRect in the program –Read the comments in the program
3
Copyright © 2002 Bolton Institute scrollv This is the equivalent of scrollh, only with vertical scrolling –Obviously, it is scrolling the “wrong way” –Again, screenRect is the key
4
Copyright © 2002 Bolton Institute 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
Copyright © 2002 Bolton Institute scrollhsprite2 This time, although it looks wrong, it is actually correct! –Both background and sprite live in the same coordinate system
6
Copyright © 2002 Bolton Institute scrollhsprite3 In this version, we move the sprite in an attempt to “keep up with” the background –But is this the right approach?
7
Copyright © 2002 Bolton Institute scrollhsprite4 This is probably more correct: –The sprite moves in world space –We move the “viewport” on the background as the sprite moves
8
Copyright © 2002 Bolton Institute scrollhsprite5 If we use this approach, we can place other sprites in world space and wait for our sprite to encounter them
9
Copyright © 2002 Bolton Institute 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
Copyright © 2002 Bolton Institute 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
Copyright © 2002 Bolton Institute scrollhsprite8 Random location of the enemies –Look out for srand(...) and rand() The s stands for “seed”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.