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 / Help Needed!

Author
Message
Simon_123
16
Years of Service
User Offline
Joined: 10th Jun 2008
Location:
Posted: 10th Jun 2008 22:22 Edited at: 10th Jun 2008 22:47
Hi,

I created a simple game in DarkBasic Pro, but there are some things that I want to do but I cannot work out how to do them. It is an asteroid game, central ship, missiles fire out of ship, ateroids are destroyed when missiles hit the asteroids.

These are the things that I want to do:

1. I want to add a counter! When an asteroid is detroyed, it should increase by one point each time. 1 points, 2 points, 3 points, etc should displayed in the top right hand corner of the screen.

2. My missile is in the wrong place! How can I make it come from the end point of the ship? I set the position but it didn't work!

3. I want to add different levels! (started this in non-working version, but couldn't get it to work!) Level one should be speed 0.5, level two 1.0 and level three 1.5.

4. I want to add a menu! In my non-working version I've actually done this but I cannot get it to work (kept the code in there). Pressing 1 should start the game on level one, pressing 2 should start the game on level two and pressing 3 should start the game on level 3. Pressing 4 should make a help menu come up and pressing 5 should make the game exit.

5. If an asteroid hits a ship, then a 'game over' message should come up, and it should return to the main menu.

6. After all asteroids have been destroyed it should go back to the main menu.

Please be as informative as possible when posting, I am an absoulte noob to all of this! If someone could do these for me, get it working and then post comments in the relevent areas so that I actually understand what is going on then that would be good also, and probably easier since otherwise its going to take ages for me to work it all out!

Working version:



www.lizardinternet.com/WORKING.zip

Non-working version:



www.lizardinternet.com/NONWORKING.zip

Many thanks,
Simon.
Lord Einstein
19
Years of Service
User Offline
Joined: 22nd Oct 2005
Location: Well here, of course...
Posted: 11th Jun 2008 16:13
Hi. Firstly you need to give the media for your game and you shouldn't ask for people to code in a feature or correct your whole project. I'll try awnser some of your questions then.

1) Add a variable. At the start just put "score=0". When the player hits an astoroid just put "score=score+1". To display the score on the screen put "text 100,100,str$(score)" in the main loop (the two numbers are screen co-ordinates fiddle around with them till you get the number in the correct place).

2) I expect that you missile is always comming out of the same place regardless of where the ship is. One way to do this is to position the missile at your ships center, then rotate it by the ships angle and then move it forward. It will then look like it comes straigt out of the front of your space ship.

3) You need to put in a speed value. before the game starts "speed#=0.5" (you need the hash if doing decimals). Then you need to change the movement thign so instead of moving the player by a set amount it is moved by speed# ("move object 1,speed#"). You then need something that puts up this speed. e.g. when your score reaches a certain value or after a period of time.

5) You can test the collision between the ship and the astoriod. "If object collision(1,astoriod)=1". You can then use the goto command to take the player outside the main loop and into another where it just texts "game over on the screen" (use the text command again). You can then use another goto command to jump back to the main loop. Look up goto commands in the helpfile I use them all the time.

6) You could either make it so when the score = a certain value or you could cycle through every astoriod checking if they exist or not.

Hope this helped.
Simon_123
16
Years of Service
User Offline
Joined: 10th Jun 2008
Location:
Posted: 12th Jun 2008 01:59
Helped a lot, thanks! However, I have not been able to get the score to work. Nothing comes up! I've also got some problems where it says the background image that I am loading does not exist, when it does! I've inputed the relevent code, but nothing appears. I've inputed most of the other things you said as well. I got the menu to work and the levels to work.

Here is the script, which includes all the media: www.lizardinternet.com/game.zip

You help is much appreciated.

Thanks,
Simon.

Login to post a reply

Server time is: 2024-11-25 04:40:46
Your offset time is: 2024-11-25 04:40:46