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 / 2d shooting

Author
Message
farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 23rd Jan 2010 03:27 Edited at: 23rd Jan 2010 14:09
i am making a 2d shoot'em up game. I am stuck on the "shooting bullets" part help would be great. Almost forgot i just want the bullets to go straight right for approx. 600px then "disappear" so i can shoot again


edit: i got it to shoot but i need help making it so i can shoot again after a certain time
code update.

thanks for the help guys.


SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 23rd Jan 2010 16:43 Edited at: 23rd Jan 2010 16:45
Looking at your code it appears that you are not resetting the firing to 0 as soon as your Bulletlife hits 0.
So for example.


Try that out. You may also want to consider putting the bulletlife into it's own subroutine.

I am Batman!
farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 23rd Jan 2010 17:25
ok thanks i will try it.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Jan 2010 17:29
I edited your code. Let me know if you have any questions.



BTW, 30FPS is really slow. The bullet only shoots to the right.

Click my sig to download TGC Heroes v0.94.

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 23rd Jan 2010 17:52
LBFN - Nicely done. I'm at work at the moment so I couldn't really go much into the code but what you did was very good.

I am Batman!
farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 24th Jan 2010 14:50 Edited at: 24th Jan 2010 14:57
Thank you very much for the help. I will try an study the code to figure out what i did wrong. Do you recommend I turn up the fps?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 24th Jan 2010 17:15
Soulman:
I see you have been around a while. It's funny that I don't recall seeing you on the forum as I used to be on quite a bit. Thanks for the compliment.

farmkid4:
You are welcome. It seems to go too slow for me at 30 fps. The player movement tends to be more jerky and less fluid (I made up some pseudo - media so that I could make sure it worked okay). I usually run at 60 fps myself, as it seems like most games work pretty well at that rate for me.

Click my sig to download TGC Heroes v0.94.

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 25th Jan 2010 22:29
I was just very busy at my previous job which kept me out of a lot of this stuff. Thankfully my new job isn't as demanding as the previous and I know have time to work with DBPro.

I am Batman!
farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 26th Jan 2010 02:30 Edited at: 26th Jan 2010 04:19
i have another question for you guys. jumping. i have this code(its a bit jerky but it works) for jumping the problem is it only lets me jump once. help would be great.


if there is a btter way to make him fall down please let me know. i fixed it so u can jump more than once

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Jan 2010 17:32
Here is how jumping can be implemented:



You had used the spacebar for firing, so I changed it to where pressing [ENTER] fires and the spacebar jumps.

Click my sig to download TGC Heroes v0.94.

farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 27th Jan 2010 03:19 Edited at: 27th Jan 2010 03:35
thank you its works quite well except for one thing. When i jump onto a box sprite and jump off it stays at the height of the box. Any ideas on how to fix it?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Jan 2010 15:59
Quote: "When i jump onto a box sprite and jump off it stays at the height of the box. Any ideas on how to fix it?"

You're going to have to check for collision with on-screen objects and will have to check whether or not there is something below the feet of your character. There are a few ways you can do this:
1. pixel - perfect collision (search the forum, there are examples)
2. using DBP's native sprite collision command - it used to be buggy, but I haven't used it in a while, perhaps they have fixed it
3. using box collision (you look at the position, height and width of your character and the on-screen item and see if they overlap)
4. use an array to display tile images on the screen. The tiles are made the same size, so you can calculate collision based upon which tiles a player is near. Again, you should be able to find examples of this on the forum.

It is worth mentioning that any bullets you use should also check against on-screen objects / enemies.

Click my sig to download TGC Heroes v0.94.

farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 27th Jan 2010 22:32
ok i added collision here is a video showing my problem http://pcsr4fun.webs.com/apps/videos/videos/show/6821593-2d-shoot-prt3

i want the player to fall to the ground (i am going to make a sprite for the ground i think.

here is my current code im not sure where to start.


LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Jan 2010 16:25
First off, the escape key was disabled on purpose. You should always delete any media that you put into a game. This is a way to do that before the program exits.

As to the collision, you will have to decide how you are going to detect when your character's feet are on the ground/platform.

If you are going to do it with sprites, you will need to make sprites that represent the ground / platform / obstacle / whatev and then check collision against them. If the character's feet are not touching the ground or an object, you cause it to fall until they do touch something solid or fall off the bottom of the screen.

As mentioned in #4 above, you can use an array to tile the background / foreground and calculate your character's position. If you want to go this route, I would suggest searching for "scroll" (without the quotes) on the forum and in the codebase. There are several examples out there.

farmkid4
15
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 30th Jan 2010 19:23
thanks for the help.

Login to post a reply

Server time is: 2024-11-16 11:09:47
Your offset time is: 2024-11-16 11:09:47