Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / moving a sprite using arrow keys until it collides with another.

Author
Message
D18AGON
21
Years of Service
User Offline
Joined: 25th Sep 2004
Location:
Posted: 26th Sep 2004 00:12
Hi, I need some help here, I would like to know how to assighn sprite annimations to the arrow keys so when i press right key the walk right sprite animation loads an plays, and also how to make it move across the screen at the same time. How do i set the speed of a sprite anim and how do i set the speed of the movement/travel of the sprite anim. Plz include source code in your answer.

I think I have attached some source code of my play anim here, what do i type and where to adjust the sprite anim speed?
Crazy Programmer
AGK Developer
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 26th Sep 2004 12:43
hey this might help
that is riches snake game it might help u the snake colides into the wall then stops if u look almost in the midle is is the speed and eaten keys that might be a good example on how to use your speed and down below that is your mouse keys see if that helps u any

that is the speed and eaten part and this is the mouse keys
there u go see if that helps u any

crzy programer
D18AGON
21
Years of Service
User Offline
Joined: 25th Sep 2004
Location:
Posted: 26th Sep 2004 14:52
Thanks for the info and snipets, but what I need to know is more sprite animation orientated and your eggsamples don't show how to do this. I simply need to know how to load and play a sprite animation when an arrow key is pressed, like for egsample:

if rightkey() then play sprite, 1
"then something here to make the animation move across the screen at a certain speed."

I need something as simple as that to show me how to do. Plz give example.

Here is my code to make and play a sprite anim:

sync on
Load Image "Image 1.bmp",1
Load Image "Image 2.bmp",2
Load Image "Image 3.bmp",3
Load Image "Image 4.bmp",4
Load Image "Image 5.bmp",5


do
inc n
if n > 5 then n = 1
sprite 1,x,y,n

sync

Loop

Question 1, what do i type and where in this code do I set the speed?
Question 2, how, and where do I incorporate this code into the rest of the program to 1: make and load 2 sprite anims, (the first to be a man just standing their when no keys are pressed), the second sprite is to be the man walking, then 2: Program it so that first the man appears where i pre programed the man to appear, then when i press the right key the "man walking sprite" anim plays.
3: How to make the anim travel across the screen in the direction i choose and how to set the speed of it.
egg.

sync on
Load Image "Image 1.bmp",1
Load Image "Image 2.bmp",2
Load Image "Image 3.bmp",3
Load Image "Image 4.bmp",4
Load Image "Image 5.bmp",5


do
inc n
if n > 5 then n = 1
sprite 1,x,y,n

sync

Loop

"the posithion for the first sprite to load (egg: play Sprite, 1,x50,y50)"

"then" if rightkey() then play sprite, 1

"then something here to set the speed of the sprite movement across screen."

"then type the code to make the sprite anim MOVE right across the screen and what speed when i press the right arrow key."

Or something like that, if thats even close to being an egsample? I really have no idea.
I need to know the code for this and what order the code goes in.

Basically if you could just do an egsample to show me what to type and where to type it in this part of my project it would be GREATLY appreciated!
LordAnki
22
Years of Service
User Offline
Joined: 22nd Apr 2004
Location:
Posted: 27th Sep 2004 09:10
please put your code in a code snippet boxy like he did by clicking the code button where u type ur message.
D18AGON
21
Years of Service
User Offline
Joined: 25th Sep 2004
Location:
Posted: 27th Sep 2004 16:20


like that?
Crazy Programmer
AGK Developer
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 29th Sep 2004 11:38
yeah a code snippet like that

crzy programer
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 6th Oct 2004 10:30
I need help moving my image. I think i need to convert it to a sprite but im not sure how to do that. I want it to move around when i press up down left or right. So heres the code... i must warn you though....its very elaborate


Weird = Unique. Unique = Human.
Crazy Programmer
AGK Developer
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 8th Oct 2004 14:16
use a comand like this
do

cls 0

if upkey() and d<>3 then d=1
if downkey() and d<>1 then d=3
if leftkey() and d<>2 then d=4
if rightkey() and d<>4 then d=2

pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 9th Oct 2004 02:46 Edited at: 9th Oct 2004 02:46
Hi

@ OOSKA
This was a tutorial I knocked up a while back for someone it may help you



pizzaman

Login to post a reply

Server time is: 2026-06-11 17:31:13
Your offset time is: 2026-06-11 17:31:13