Pages: 1
Topic closed
How do i make accurate x and y scrolling such as going to a door and seeing treasure, or walking through another door and fall into a trap or villain. This leads me to my second question. How do I get a enemy in my scroller, an example of this is in Archknight adventure. An example of two way scrolling is privateer.
xjediboy11
Offline
IF you look at my Zombie hunter 3.4.1 proj. That's a good exaple of scrolling.
Scrolling:
If left arrow key pressed then change enemyx by 1. This is how I would do it, by making the enemy move in the opposite direction of the player every time the player moves.
As I said earlier, check out Zombie Hunter 3..4.1!
Happy Scratching!
Offline
When I programmed archknight's adventure this is how I made the enemies.
Since the game only moved left and right, there was only 2 variables in the script.
scrollX for controlling the position of the terrain and objects.
freeMoveX for letting the sprite move about
The code that moves the sprite was
when green flag clicked
go to x: ( scrollX+freeMoveX)
Then to made the enemies move left and right I changed the freeMoveX variable.
Like this
when green flag clicked
forever
repeat 10
change freeMoveX by 3
repeat 10
change freeMoveX by -3
If you want it to move do the same thing for sprites that move up and down you do the same thing except you use the y variable.
If you really understand how scrolling with the x coordinate works you should have no problem with scrolling the y coordinate.
Each full sized sprite is 480 units wide and 360 units tall. In order to show them side by side we space them by multiples of their width which is 480.
so if sprite 1 is moving to 480 and sprite 2 is moving to 480*2 then the sprites will appear side by side.
Since each sprite is 360 units tall to make them appear one on top of another we would change their y coordinate by their height or in this case 360.
So basically for vertical scrolling you would use this code, just put the scrollY variable in the same way you did with the scrollX variable.
//on sprite 1
go to y: (360*1)
//on sprite 2
go to y:(360*2)
and so on.
I really recommend that you know how the codes you use work because if you don't when you get stuck you won't be able to fix your program.
Last edited by archmage (2008-10-22 16:40:49)
Offline
Topic closed
Pages: 1