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 Shooter questions, help needed!

Author
Message
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 24th May 2010 20:02
My friend and I are making a top down 2D shooter in class for a project. We are meant to be a group of 4 ,but the 2 designated programmers have left. We are using Dark Basic Pro

We're using self created sprites as well. I was wondering if you guys could help us with some of the coding of the game.


We have tried various different things which don't seem to work well. Basically we are using arrow keys, left and right to rotate and either space or mouse button to shoot.

If our group hadn't had lost two of its members then we would have stuck to our more original Idea however, we thought the best approach is to make it similar to "I made a game with zombies in it" on XBLA except with a fixed camera.

The troubles we face are:

Rotating the main character properly ( It doesn't seem to rotate on the dot and its very slow)

Having bullets fire out of the character rather than where the character originally was and having it rotating.

Setting some sort of collision around the edges of the screen
and on some sprites we will place in to avoid player walking in to building, a zombie or zombies in to buildings or other zombies.

The player is only going to have 1 life, 1 bullet to kill a zombie. 2 bullets to kill a fat fudge zombie and 3 for the butcher. The player will die if any zombies touch him.

We plan to have 3 levels introducing the fat fudge in 2nd and butcher in 3rd.

3 Guns pistol firing 1 bullet, Shotgun 3 that spread out and machine gun stream of bullets, no ammo or pick ups needed.

We've been scratching our heads trying to do this in the midst of a hundred other projects that need to be handed in. So anything that you can help with above or things you feel may be useful please let us know... Thanks guys
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 25th May 2010 13:46 Edited at: 25th May 2010 13:47
4 people are too many for a project like this.You 2 are ok, even 1 man alone can do it.

You need to devide the work so you can do it faster.Do it on pieces then assemble it as one.

About the troubles you are facing, pretty much the whole game.If you don`t know where to start from, just start from tutorials!Search the forums and you`ll find what you are looking for in most cases.

EDIT: O yeah and good luck with the game!

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 25th May 2010 15:11
Yeah we do realize this its just our time has been cut short, we have been breaking it up. I understand that we're asking a lot but even on 1 topic would help. We're looking at it from two people who don't know where to start. Thanks for the advice we defo will check all the forums for tutorials and help but if anyone can offer anything it would be of great help. Thanks
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 25th May 2010 15:14
We're trying to load our sprites into darkbasic but they are turning out black. Also if we try to add a background our screen is black as well.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th May 2010 17:19 Edited at: 25th May 2010 17:26
I agree with luskos; you could do this yourself. Even you have an extra person to help, that is even better.

Quote: "Rotating the main character properly ( It doesn't seem to rotate on the dot and its very slow)"


Since you have not posted any code, I can only offer suggestions. Look up the OFFSET SPRITE command. As to the speed the main character rotates, this is easily changed by increasing the amount of angle used with the ROTATE SPRITE command.

Quote: "Having bullets fire out of the character rather than where the character originally was and having it rotating."


You would look at the character's current position and angle and would fire from that location and at that angle. SPRITE X(sprite #) and SPRITE Y(sprite #) will give you the character's current location. Return Float = SPRITE ANGLE(Sprite #) will give you the current angle.

Quote: "Setting some sort of collision around the edges of the screen"

I would suggest you search for 2D TILE on the forum. Collision is relatively easy with 2D tiles and you can make a large map that will cover several screens. If you are only using one screen, you could simply check the sprite's X / Y location to see if it is in bounds.

Quote: "We've been scratching our heads trying to do this in the midst of a hundred other projects that need to be handed in."


Sounds like you are pretty busy. It takes time to learn how to code. As luskos said, tutorials are a good idea for you to develop the skills you will need.

EDIT:
Quote: "We're trying to load our sprites into darkbasic but they are turning out black. Also if we try to add a background our screen is black as well."


Are you using DarkBASIC Classic or DarkBASIC Professional? It will make a difference. I can't say that I have ever seen a sprite turn out black in either one. Are you using the backdrop and are you using v7.4 of DBPro? If so, look up the TEXTURE BACKDROP command. If not, you could paste an image the size of the screen at coordinates 0,0 in every iteration of the game loop to serve as a backdrop.

It might be easier to help if you could post some / all of the code you have. Please click the CODE button, paste your code and the click the CODE button again in your post. This will put it into a snippet box.
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 25th May 2010 21:46
Ah how did you made TEXTURE BACKDROP work?My dbpro say it`s obsolete comand and restrict me from using it.I need it for shortening some part of a project few lines, i`m currently using textured plain positioned at desired place so it cover the whole screen.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th May 2010 16:45
Quote: "Ah how did you made TEXTURE BACKDROP work?"


This command was put back in to DBPro v 7.4. You can easily check your version in DBPro by going to HELP, ABOUT. Should be 1.074.
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 26th May 2010 19:45
I`m with 1.075 they took it again maybe?

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Dark Dragon
17
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 27th May 2010 02:53
You could take a look below(my sig). is this what you are trying to create? if so, i'll help ya.

Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 29th May 2010 21:06
We're using Dark Basic Pro we downloaded from this website, yeah we're having a sniff at tutorial. I'll get the latest code from the guy and post it up.

@ Dark Dragon, Sure that would be awesome and greatly appreciated its not exactly the same idea but its pretty close, PM your MSN and we'll discuss further.

Yeah, I agree that we could have got it done, if the group was more organized, however its not just the game we have to do a tonne of written work and mock meetings agendas and minutes which the previous members buggered of with when they left the course and have never came back. Its also including essays about research and such and well I never got a choice about whom to work with and it just so happens those people left, I've taken my current partner to form a 2 man group due to a falling out with his friends so we just really got together cramming in massive amounts of work in, with so little time. To allow us to finish up anything we aim to actually have this completed by monday night/tuesday. This whole year has just been a complete mess the course has just been really bad. This is only one class and of course I want to walk away having learnt something rather than being totally stressed out. Over the summer I plan to look over Dark Basic so that I'm actually confident with it as well as other programs such as Blender animation.
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 30th May 2010 02:55
Dark Basic Pro downloaded from this site

@ Dark Dragon, yeah that would be great its not exactly the same but I think a lot of similar coding will apply. PM me your MSN or something Thanks very much
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 30th May 2010 16:23
This is what we have so far, we can't seem to get our sprite loading to replace the red/green square or getting an image to load in the background. If you press space bar you will see bullets fire but we're trying to fix that on the square where the gun should be. We have object collision which seems to end the program when we hit so we have taken that out. The green square represents the zombie which we know how an objects chases an object but not a sprite chasing a sprite as it doesn't recognize the code since we just replaced object with sprite. I'm looking for code to set around the area so the player and zombies can't walk out and so the bullets timeout once it makes contact.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th May 2010 22:27 Edited at: 30th May 2010 22:36
Quote: "we can't seem to get our sprite loading to replace the red/green square or getting an image to load in the background"

You are drawing the boxes incorrectly. At lines 18 - 19, you have


You started the box at pixel 50 and ended at pixel 9. This will not put anything on the screen. It should be:


Same thing with lines 27 - 28. You have:



which should be:



As to the background, I made up an image in place of your "textures-26.bmp" image (perhaps you could post the image you are using - it may be the problem.)

Quote: "If you press space bar you will see bullets fire but we're trying to fix that on the square where the gun should be."

I press the SPACEBAR, but no bullets are seen. I definitely would recommend using an image instead of text for the bullet, as it is way too slow and harder to use than making an image and using a sprite for it. Additionally, the text is straight up/down. What if the player is shooting to the side? You'd have to rotate it and stuff...kindof impractical.

Also, the code:



does not truly offset sprite 50 at it's center, as a$ is not defined in the code at all. Use 5 to offset it instead:



Additionally, sprite 50 is the green square, which you said represents the zombie. It really doesn't matter, so I set player to = 50.

You are using three arrays for the bullets:


I would suggest using one array with three elements, like this:


Other notes:
__Use wrapvalue() to keep an angle within acceptable angles (see example).
__Typically, you will use SYNC at the end of your game loop. You would not want to add another SYNC in a subroutine, as it will dramatically slow down your game. I removed the one you had installed and I had to edit the speeds for everything as it simply was too fast.



I have revised your code a little bit. Take a look at it to see if this is what you were hoping to accomplish:



I have attached the image that I used for the bullet.

Hope this is helpful.

LB

Attachments

Login to view attachments
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 31st May 2010 19:19
Thanks bro I really can't emphasise how grateful and appreciative I am that you took your time out and to reply and show me the code you altered. So again thanks You've been very informative and kind and I read somewhere about nominating someone for a moderator and I would recommend you if I have enough say, if that's something you'd be happy with.



I tried the code you send and collision works perfect around the edge. I tried the firing to see your bullet sprite in action but it wasn't working. The movement is a lot better bro thanks

I have the images, just to show ya since we still need to cut em out, but just download em. The zombie one will be multiple as this is the common zombie.


The guy whos in my group asked to ask about getting the zombies to chase a player/sprite chasing sprite. This is the code we used when we had a 3D version of the game we were testing



Basically the black ball would chase down the white ball and that was it but we can't get it working when chasing object to sprite. We realize the Z axis is in there.



This is the rest of it.




This is our collision code for the buildings we will put it, but my partner says it closes the program.

Thanks again

btw trying to upload the files says its over 50mb when its not
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 31st May 2010 23:12 Edited at: 31st May 2010 23:29
Quote: "Thanks bro I really can't emphasise how grateful and appreciative I am that you took your time out and to reply and show me the code you altered. So again thanks You've been very informative and kind and I read somewhere about nominating someone for a moderator and I would recommend you if I have enough say, if that's something you'd be happy with."

You are very welcome. My hope is that your project will turn out well for class. Being a MOD would be okay. Thanks for even suggesting that, but I won't hold my breath.

Quote: "I tried the firing to see your bullet sprite in action but it wasn't working."

It works great on my computer. However, I made up a background and yours is undoubtedly very different, and you may not be able to see the bullet. (I assume you installed the bullet image file I uploaded into the folder with the game's .dba file). You could either put in a temporary background that is very light or could change the color of the bullet (just use MS Paint to edit it) so that it is a color that will show up with your background.

Quote: "The guy whos in my group asked to ask about getting the zombies to chase a player/sprite chasing sprite. This is the code we used when we had a 3D version of the game we were testing"


It is relatively easy to do this with sprites also. Simply look at the sprite coordinates using the SPRITE X and SPRITE Y commands and move the zombie sprite accordingly. You would have to put in the logic so that the zombie can make it's way around buildings.

Quote: "btw trying to upload the files says its over 50mb when its not"


Do you have WinRar? If not, you can google it and get a trial version of it. You can then compress all of your files into one .rar format file. Much quicker/easier to upload/download files.


EDIT:

I added some code to show you how you can make the zombie chase the player. It is not perfect, but should get the idea across. This uses the command TEXTURE BACKDROP, so you will need DBPro v 7.4 to use it.


Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 11th Jun 2010 16:08
Hey LBFN sorry its been so long since I have replied, the course has extended a week due to a lecturer leaving so we had to do all his work this week since he decided he was leaving. So we have been so busy. That is us back on to our game.

Thank you so much that works brilliantly. The lecturer suggested we make it one never ending level to reach a high score, so its fun to compete against peoples highest scores.

At the moment myself and my team mate are working a lot on the paper work and looking out for code for the bullets to kill the zombies, wonder if we should do a simple blood splatter and then make them disappear or whatnot. We're also gonna check out code for re spawning the zombie out side the screen from all different directions getting progressively more and more.

We'll get some code n show you what we come up with mate. I'll get onto messaging the appropriate person to recommend you as a mod, I just don't know who to speak to
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th Jun 2010 18:33 Edited at: 12th Jun 2010 18:34
This code will place the Zombie randomly off the screen. It also accurately tracks the number of bullets on the screen. When the zombie is shot, it fades out and re-spawns off the screen. You could easily increase the difficulty by adjusting the player's speed, zombie speed, or adding more zombies.



I have added comments to the code to help you see what it is doing. Let me know if you need help with anything else.
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 12th Jun 2010 22:23
That codes great bro, the problem is I don't have the sprites cuz I got the free DarkBasic that loads from this so I can't see the bullets. It does look like the zombie does die even if the player isn't facing him.We had found some code we tried to get working which was the bullet hitting the enemy. Everything else works fine We just need to get these sprites loaded, the bullet more accurate and more zombies on the screen. Thanks dude I'll mess around with the code after some of the paperwork and let you know if I come up with anything. Is there a place to get the Dark Basic pro free that allows us to see our sprites?

Thanks for continued support mate
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 13th Jun 2010 04:18
Is there a place to get the Dark Basic pro free that allows us to see our sprites? - Dariman

What do you mean? The free version is exactly the same as the full version. I have run the above code and see no sprite, even if I load a dummy up for it. I haven't gone any further than that, but something is still wrong with the code. It is not your version of DB.

http://s6.bitefight.org/c.php?uid=103081
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 13th Jun 2010 15:22
Ah right DVader, cuz in our course the sprites loaded but then at home it doesn't we know the version in our course has to be paid for though, that's why I was asking if there was a problem with the version.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 13th Jun 2010 15:51
Quote: "That codes great bro, the problem is I don't have the sprites cuz I got the free DarkBasic that loads from this so I can't see the bullets."


The free version of DBP is going to allow you to display sprites. The Zombie and player are both sprites and from your posts, you can see them, so using the free version of DBP should work fine. If you don't see the bullet, then either you did not download the bullet image I posted or the image does not reside in the same folder with your .dba code.

Running the code without media, I get this:




I stated that I have supplied a background, as I do not have your file "textures-26.bmp". I mentioned that in order to see the bullet that I made, you will need a light background.

Quote: "I have run the above code and see no sprite, even if I load a dummy up for it. I haven't gone any further than that, but something is still wrong with the code."


This is incorrect. The sprites are simply a red box, a green box and a small bullet. You can see all three in this pic:



I think the issue is related to the images for the bullet and / or the background texture. If you want, I can upload the background texture I am using, but you could easily make it in MSPaint.
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 15th Jun 2010 18:36
Hey, thanks Yeah we tried loading the bitmaps into it in the exact same folder ill attatch the images.

Ok this is our code so far, our deadline is friday so my partner and I will work on and finish it by thursday night.

We tried adding code to increase the starting zombies, we don't know if we should have it gradually getting harder as the game level does not end until you die which brings us to the second problem. We don't want to overcomplicate things so we don't mind just making it hard from the start and keeping that diff, if it is easy then just increasing the zombie count for every 20 zombies killed.

We are trying to implement a score board that will attatch to our menu, see next. Basically you get 10 points for each zombie killed and once you die the game records your score and 3 letters of your name like at the arcade. Once you die it asks you to record your name and records the score with your name and places it on the High score section on you main menu. After recording the score you can go back to the menu to start a new game or quit.

We have implemented a menu into the start of the game which you can't see but if you press down arrow key and press enter then text will appear, we want it so that you won't see the game until you click new game. The High score section is included for when we get a highscore table.

If theres anything that you can help with that would be greatly appreciated and we thank you for all the effor you put in so far. I noticed you have an email button under your post, if it's okay with you then would it be possible for me to email you my email address so we can talk over msn or whatever you use?

Thanks again mate this course has just been a riot

Attachments

Login to view attachments
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 15th Jun 2010 18:46
Also this is our sprites zombie and player.

Attachments

Login to view attachments
Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 15th Jun 2010 18:47
This is the zombie

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Jun 2010 00:28
Quote: "If theres anything that you can help with that would be greatly appreciated and we thank you for all the effor you put in so far. I noticed you have an email button under your post, if it's okay with you then would it be possible for me to email you my email address so we can talk over msn or whatever you use?"


Okay, I will try to help you with the code. Since you are relatively new to DarkBASIC Pro, I haven't mentioned anything about TYPE variables, but it would be easier to understand and to code if they are used. You seem to have grasped some things so far, so I will put together something that includes the use of them and perhaps you will be able to learn from it.

Sure, you can email me if you like. That is probably the best way to get a hold of me. I have an MSN account, but I never use it.

I prefer to use SKYPE, but I don't want to post my address here. [www.skype.com - you can set up an account for free if you don't have it already.] If you email me, I will send my SKYPE address to you. Bear in mind that I work at my real-world job a lot, so sometimes it is quite a while before I can get back. I am on CST (Chicago; USA) time.

LB


Dariman
14
Years of Service
User Offline
Joined: 24th May 2010
Location:
Posted: 16th Jun 2010 00:39
I have skype I will email you and then send me your skype

Login to post a reply

Server time is: 2024-09-28 18:23:43
Your offset time is: 2024-09-28 18:23:43