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.

Newcomers DBPro Corner / Jumping animated sprite

Author
Message
Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 11th Jun 2006 13:07
Hi all

I have read some other posts on jumping, but I'm finding it hard to understand, I would be really grateful, if someone could explain to me in lamin's terms( and I mean real basic ) how I would get my jumping code to work

Thanks !!!

Attachments

Login to view attachments
Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 11th Jun 2006 13:09
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 11th Jun 2006 17:49
I use DBC, so the code might not work, but it should since it doesn't use any complex commands. It it doesn't, then there might be a command or two to change. I can't help you with your program, because I don't have DBP, but I can show explain how to add jumping into your program.

Here is a simple circle jumping program. Just modify the jumpx# and jumpy# at both the beginning and within the loop to change the jump.

If there is something you don't understand, just ask and I will explain it.

Hope it helps!



Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 11th Jun 2006 19:33
Hey thanks UFO

I have tried to use your code within my own and it seems to do the trick, I have just noticed that when trying to jump left, if you let go of the left direction key the sprite freezes, now I really struggled to get the animated sprite to work in the first place.

Have I done something wrong ?

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 11th Jun 2006 20:05
I will try to get your code to work with DBC in a couple minutes. But here is a few changes I made to my code:



I totaly got rid of the jumpx variable because the left and right key already move the circle left and right, so you don't need the jumpx variable. I see that you already got rid of it, so whatever

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 11th Jun 2006 21:34
ok. Yes, you did something wrong
Here are the changes I made:



I commented on the lines that I modified. I had to change a few things for it to work in DBC, but I didn't change those in the code above.

Hope it helps!

Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 11th Jun 2006 23:04
Hi UFO

Thanks for helping me out, I'm still new to this programing lark and this is my first attempt at sprite manipulation using the CREATE ANIMATED SPRITE COMMAND.

I have played around with your suggestion and modified it slighly to allow the sprite to jump over the box in the centre of the screen. it works really well, the only problem I have is, if you initialy press the leftkey followed by the right key the image does not mirror correctly, any ideas ?

by the way, I am using DBP, and thanks agaiin for all your help !!



UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 12th Jun 2006 01:22 Edited at: 12th Jun 2006 01:24
I think all you need to do is to say

"Direction = 1" or "Direction = 1"

Here:

y=400
jumping = 0
jump#=-8
Direction = 1

And no problem about the help. I am not yet into the mood of working on my game, since I haven't programmed for a while because of school, which is finally out (thank god!). It helps to have something else to occupy some of my time besides working on my current game. It also makes me feel good

Also, if you need any help about being able to land on higher areas, like the box, I am willing to help.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th Jun 2006 05:10
Hey, I found another way to make jumping sprite thingys! I just changed UFO's code it's a little different hope u don't mind UFO. Your code was cool


GOOD FOR YOU! YOU FINALLY DREW A PERFECT SQUARE AFTER ALL OF THOSE LONG YEARS! Well, only fifty-nine more to go before anybody will notice.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th Jun 2006 05:12
In the last post I made on this you use the arrowkeys to determine jump direction while you're in the air! Feel free to edit it, but again, Good Job UFO.

GOOD FOR YOU! YOU FINALLY DREW A PERFECT SQUARE AFTER ALL OF THOSE LONG YEARS! Well, only fifty-nine more to go before anybody will notice.
Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 12th Jun 2006 22:30
Hey sixty

Thanks, I have attached an ammended version of UFO's coding with my absolute abortion of an attempt at sprite collision, I knew I was bad, but hell................

Anyway if your you or UFO have nothing better to do, maybe you can check it out (have a laugh ) and maybe show me the error of my ways.

By the way thanks for your previous post UFO

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th Jun 2006 22:49
I do not have "man.png"

GOOD FOR YOU! YOU FINALLY DREW A PERFECT SQUARE AFTER ALL OF THOSE LONG YEARS! Well, only fifty-nine more to go before anybody will notice.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 12th Jun 2006 23:26 Edited at: 13th Jun 2006 00:38
Sixty Squares, I don't care what you do with that code You can try to sell it and I wouldn't mind
But the program is kind of messed up...withever you don't press right or left, the circle rises straight up


Also, when I was testing his code, I just replaced man.png with another image. It shouldn't make any difference...


Ant, I will get to work on it

EDIT: lol, that is terrible. Um...I mean...its not that bad lol...uh.... The side collisions are fine, but the top is messed up. Its fun standing on it and keeping space down .


EDIT: I am thinking of a way to do it. But I am tired right now, so I will try to answer it tomorrow (Its 5:30 where I live).

Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 13th Jun 2006 00:47
Quote: "
I do not have "man.png"
"


Man.png is attached as a download on my original post at the top of this thread sixty, or at least it should be.

Although it was a rough attempt at making an animated sprite from an sprite page I downloaded from the internet and although it's 16 frames, only four of them are different, so really you could just code

PLAY SPRITE 1,1,4,200

to obtain the same effect, hey thanks for your help again UFO.
You know if we carry this on, you may even get to teach me how to program Donkey Kong, cool game. Although I'll probably fall at the first hurdle.
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 13th Jun 2006 01:31 Edited at: 13th Jun 2006 23:34
I suggest doing something easier first, like a simple shoot-em-up. That's what tought me to program at the beginning. The first game I made that really helped me is in the 20-liner board. Its called Laser Assault.



Sorry for the ad

D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 13th Jun 2006 22:54
I wrote a sprite jumping routine a while ago. It uses trig. to calculate the sprites position during the jump.
I,ve used a variation of this in several of my projects. It will work in DBC and DBPro.



This code uses the joystick to move the character, but you can change the controls
to use the keyboard at then beginning. The routine is also set up to use a 384 x 384
sprite at the bottom of a 1024 x 768 screen. The code doesn't use any sprite offset commands.
The offset is figured into the code for the jump portion. It also controls walking and a simple
sliding effect. An idle sprite animation is also handled when the player does nothing with the
character controls.

Sprite Animation Break Down For Frames:

Idle = frames 1 to 30
walking = frames 31 to 60 (frames 31 and 46 plays footstep sound)
Jump = frame 61 (with jump sound)
Slide = frame 62 (with sliding sound)

Variables:

aflag = sprite mirroring flag
jump = lock out flag to disable player controls while sprite is jumping.
slide = same as jump, but for slide
x = current sprite X pos (origin not offset)
y = current sprite y pos (origin not offset)
frame = sprite image number

The input for control part is not exactly optimized, but it works.
You can tailor this code a way you wish and use it in your own game.
If you need help with figuring out with what everything does, let me know.
Ant
19
Years of Service
User Offline
Joined: 27th Nov 2004
Location:
Posted: 17th Jun 2006 12:29
Have improved collision detection slighly, but sprite still slides off box, I assume I have to set speed to 0, but can`t seem to figure out where to put it, in my code.

Also, not too sure about how to alter the bounding box on the sprite, to allow my character to collide properly, is it the OFFSET SPRITE command ?

An explanation or example or both would be good !

Thanks D Ogre for your last post.

D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 18th Jun 2006 20:49
DBPro doesn't have pixel perfect collision like DBC has. You can use the sprite collision
function written by IanM in the code base. Search for pixel perfect collisiion.
Use his collision function instead of SPRITE HIT() or SPRITE COLLISION().

The offset command will shift the position of the drawn image without affecting the
coordinate of the specified sprite. You can use this command to change the
visible sprite in relation to the coordinates you use to position it.

Login to post a reply

Server time is: 2024-11-26 17:26:11
Your offset time is: 2024-11-26 17:26:11