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.

DarkBASIC Discussion / help with 2d rpg

Author
Message
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 11th Jul 2007 05:26
hey guys, how do you move a sprite thats not the player? I need to move it in small increments at a time without using the controls(i.e. therefore making it AI, sort of!)
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 11th Jul 2007 05:53
well, put it in a for...next loop. position the sprite at t (or whatever the variable is). Use the STEP command to increase speed. (example: for t=1 to 100 step 5).

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Jul 2007 06:38
@DD

Just simply assign a number (you could use a variable name that has an assigned value) to the sprite that is not the player and move it by changing the x/y values using the SPRITE command. It's really no different than moving the ghosts in pacman, for example.

A For-Next loop would work if that was the only sprite you are moving, but in a game you will likely have several objects moving within the same do - loop. I would suggest using arrays to keep track of your sprite's position.

LB
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 11th Jul 2007 14:53
actually, a for next loop worked - Problem solved!
Thanks!
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Jul 2007 15:18
@ DD

Okay, I'll stick with my arrays.

LB
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 15:36 Edited at: 13th Jul 2007 15:47
@DD

I agree with LBFN, I used arrays to keep track of the position of all objects in my 2D program. Then instead of moving the player, I moved the entire world around him (in the opposite direction) this way he stays in the centre of the screen .



Then if you want AI characters to move you can simply edit their arrays further.



Don't know if that would actually work but you get the idea.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 15:54
hmm.....
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jul 2007 16:02
Quote: "hmm..... "


What does that mean?

Sorry, I made my example a bit needlessly complicated, its really pretty simple. Just move the AIs normally and remember when moving the player to leave him in the centre and move everything else in the opposite direction.

Why do you need to move the AI characters in small increments? Tell us more about the game.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 16:06 Edited at: 13th Jul 2007 16:07
well, I've got the game set up like advance wars or age of empires.
so, it's on a tile-based system. I get what you said earlier now.

Login to post a reply

Server time is: 2026-07-06 11:38:29
Your offset time is: 2026-07-06 11:38:29