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 sprites

Author
Message
Mr Inquisitive
21
Years of Service
User Offline
Joined: 5th Feb 2005
Location: Who Cares?
Posted: 20th Jul 2005 13:46
okay, so...I have looked all through this site, and even posted a few posts myself) and I HAVE NOT YET FOUND THE ANSWER TO MY QUESTION!! Now I am going to try to get to the bottom of this. Okay so let me make this VERY CLEAR.

(1) I WORK WITH DARK BASIC CLASSIC! Don't post here with help for pro!

(2) I need to know how to make my character in my game move. Now, I haven't, nor do I plan on making a .gif character, and moving him around.

(3) I am going to try to be as patient and helpful in any way I can in order to get a straight answer to my question.

(4) My character is just four images, and I have gotten down making the guy basicly animated. In fact, THAT'S working wonderfully. So now I ask of you, how can I modify my code to make him move properly too?

I thank thee heartily, if thou dost comply.



Horus Game Developments
freewebs.com/horusgames
Robot
22
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 20th Jul 2005 15:23
I haven't tested this but it should work, just say if anything goes wrong.


The happenings of tommorow are behind us now
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Jul 2005 16:36 Edited at: 20th Jul 2005 16:51
There are several things that can be done to improve on your code.

One of the first things you need to learn is forcing the resolution. Not everybody uses the same resolution so you need to force it on people to make sure what you made is being shown exactly how you want it. "set display mode 640,480,32"

You have "sync on" which is good but you need to add "sync rate 0" to have the computer run as fast as it can while running your program.

As Robot posted you need to have sprite commands in the do loop. You had them outside the do loop causing them to never be updated with the movement changes.

You have a full screen sprite as the main menu (I assume since you didn't upload media). All that does is slow down your program. It's better to paste the image to the screen.

I rewrote the menu code a bit to use while instead of a if then loop (just 'cause I like it better ) And I moved it outside of the main do loop of the character movement. Normally you don't have title menu checks in the middle of gameplay (just in case something goes horribly wrong and a title menu pops up while you're moving).

You don't need to have 4 separate sprites to achieve animation. The last number in a sprite command is which image to use. That is what needs to be changed instead of hide sprite such-n-such to animate a sprite... the less sprites you use the faster the game.

And of course to get the character to move properly you need to use the right variable and subtract or add to get the right direction (as Robot did).

Up = chary - ##
Down = chary + ##
Left = charx - ##
Right = charx + ##

That's about it. Hope this helps:

Mr Inquisitive
21
Years of Service
User Offline
Joined: 5th Feb 2005
Location: Who Cares?
Posted: 21st Jul 2005 00:19
hank you both so much! He's walking perfectly, and, now I can move on to the more complicated aspects of this game. I shall not forget thy names, if thou dost wish it, then thy name shall be appointed credit, for helping a challenged person in need...and again, thank you...

To be or not to be-that is the question. Whether tis nobler in the mind to suffer the slings and arrows of outragous fortune...Well you know the rest...And if you don't, YOU SHOULD!!
Mr Inquisitive
21
Years of Service
User Offline
Joined: 5th Feb 2005
Location: Who Cares?
Posted: 21st Jul 2005 05:53
hehe, Thank*

To be or not to be-that is the question. Whether tis nobler in the mind to suffer the slings and arrows of outragous fortune...Well you know the rest...And if you don't, YOU SHOULD!!
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Jul 2005 12:11
Your welcome... twice.
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 29th Aug 2005 17:18
In case you were wonderin' the only reason your code did'nt work was because you just wer'nt "repasting" the sprite with its modified coordinates. OH, and by the way. I've never seen that kind of animation. The animation i use just has a variable for the image number. In the loop it just incs or decs. Once it reaches the end i make it start over.

Weird = Unique. Unique = Human.
Im human.

Login to post a reply

Server time is: 2026-07-08 08:31:43
Your offset time is: 2026-07-08 08:31:43