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.

DarkBASIC Discussion / Help me implement bullet shooting into this code.

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 6th Jul 2004 06:45
Hi, a while back I started a post entitled "placing objects with mouse", it was for a turn based stradegy game, Aura, whent out of his way to help. But that thread has long but pasted, and I am left with one more troubeling delemma, bullets. you see, I want to be able to select the unit, and be able to shoot with the space key. sense alot of this code was made by Aura, I have a hard time figuring out exactly what is going on, thus its hard to implement thing (great code though). My original design was that the player would have to hold down the space bar to shoot farther, the longer you hold down the farther it goes. so that the players have to learn to get the shot just right to hit the enemy. I also want the the players turn to be over right after they take the shot. I know this is alot to ask for, but I really want to complete a project. Here is the code....



there are some models and textures in there, just replace the "load object" command with a "make object cube", and delete the texture bit.

Thanks.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 7th Jul 2004 07:49
could someone please help me, I really want to complete this game.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
dj BlackDragon
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location: who knows
Posted: 7th Jul 2004 11:46
I'll help.If this doesnt do it ill post some code. Check the codebase that should have some stuff or you could try other threads.If this didnt help ill post with code later.That way you could incorporate it into your own and ill explain if you need it.
bye,
Ian

Current Project:Quest for the Five Staffs of Draconia
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 7th Jul 2004 14:00
Well I know how to shoot bullets, but the problem is, that in this code, when you click on an object it becomes selected, now my idea was that when the space bar was pressed, it would re-position the bullet to the selected objects position and then move it forward. But I couldnt get it to work, I tried something like....

if spacekey()=1
position object b, object position x(selected(0)),object position y(selected(0)), object position z(selected(0)).
move object b, 1
endif

But that didnt work. But even if it did work, it is not within my original design, which was to have a "power" system, the longer the spacekey was pressed the longer the shot would travel, being the newbie I am, I have no idea how to do that.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Balid
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 7th Jul 2004 14:16
Major Payn,

You need to move your bullet each loop.

Something like:


Balid
CornStalks
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location: Utah
Posted: 8th Jul 2004 00:47
I agree with Balid, but if you want it to move... here ill just write some simple code

sorry, its sort of messy, but once you read it and see it, you will get the hang of it. Im not sure if its the best code, but I think it will work

dang im hot...
CornStalks
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location: Utah
Posted: 8th Jul 2004 00:50
aaaaahhhhhhh, i forgot to put the for next command...ignore all the code above that i wrote


dang im hot...
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 8th Jul 2004 01:23
Melted Gummy,

There is an edit button...

It's right below where your name and location is, just next to where it says "Back To Top".

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 8th Jul 2004 08:51
Thanks, but I get an "unrecognized perimeter" on the line were it says "dist= dist+1". Here is my code so you can see if I am doing anything wrong....



I marked the bullet code using a bunch of exclamation marks.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
CornStalks
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location: Utah
Posted: 8th Jul 2004 09:00 Edited at: 8th Jul 2004 09:14
hehe thnx jess...
anyway, most likely the reason you are getting that message is because i never looked at you code. since i never looked at you code, i wrote words in instead of object numbers and stuff. Just go through the code i gave you and change things. Here is the code agian but different. The words in caps lock will show you where you need to modify this code for you programs...and delete the parenthases around the caplock words

The reason there was an error there is because i tried to put a remark there but it couldnt read it. Oh, and sorry, I delete all the (selected(0)) things.

dang im hot...
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 9th Jul 2004 03:38
I tried it again, but I get a "paremeter mismatcy, object position z expects integer at line 178" I dont know what they are talking about as that peice of code was supposed to position object b? Here is the code again....



P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Balid
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 9th Jul 2004 14:45
Major Payn,

Is this the line giving the error?

position object b,object position x(selected(0)),object position y(selected(0)),object position z(selected(0))`these should be the selected object's coords


If so then move the comment from the end of the line (I think that is causing the error), to may be above the line of code like your other comments.

Balid
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 10th Jul 2004 03:38
Thanks Balid I dont get that error anymore, but it seems to have picked up another one, it says nexting error at line 190, which is in the bullet code... here is the code I have for shooting...



does anybody know why Im getting the nesting error?

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 10th Jul 2004 03:41
wait never mind, I removed one of teh endifs and it works now, but I got a seriouse problem, when I press spacebar to shoot, the game locks up and I cant do anthing anymore. Here is the code once more....



P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jul 2004 07:30
can anybody tell me what to do? my game locks up when I try to shoot. I would like to figure this out.

Thanks.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 11th Jul 2004 08:48
Quote: "space=spacekey()
while space=1
dist=dist+1
endwhile"


Because your variable space never changes within the while loop.

Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jul 2004 09:06
ok, so how do I fix that? I know, I know, Im stupid,

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 11th Jul 2004 13:13
Change it to:


Done.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jul 2004 13:27
Thanks, but now I get an object does not exist error, I bet its talking about the bullet object, as the error only shows up when I press the spacekey, any idea why its not picking up the object? Here is the code....



Man I just get one error after another.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jul 2004 14:04
ok I fixed the object problem, and I dont get any errors anymore, but when I press the space key the game will still freez up, and the bullet wont shoot, I am stating to think this will be another failed attempt to make a game , I just cant figure out why it freezes like it does. The longer you hold the spacekey the longer the freez lasts. Here is my code as of now....



P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Kohaku
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 11th Jul 2004 14:07
Hey Major Payn, sorry I never continued the code but I've got into a team thingy since and am coding all the time... Even then.

Looks like your doing grand though with the help of some other people here. Cheers other people.

Infra-Dark
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 11th Jul 2004 19:05
Quote: "Man I just get one error after another."


I'll be honest with you... You're better off rewriting your code.

Kohaku
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 11th Jul 2004 19:47
Hmm, that code has got rather messed up since I last saw it. If I have some spare time soon, then I'll add the whole bullet thing to it.

Infra-Dark
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 12th Jul 2004 00:22
Aura, don't do that, the Major here needs to learn how to code himself.

He's been around long enough to know what to do, if he can't solve something small like the problem he had before then I don't think he's going to go anywhere fast.

And so far it seems that you have written his entire game for him. It's a shame really.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 12th Jul 2004 02:11 Edited at: 12th Jul 2004 02:26
I could probably code it again, but I really dont understand how he did all the object placement and timer stuff. I know how to code to some extent, but I just dont know how to do some major things in this project.

By the way, what is the easiest way to position an object at the mouse position, so that it becomes the cursor, that is one thing that was in the old code that I need to understand if Im going to try and create it from the ground up again.

P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.
Kohaku
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 12th Jul 2004 05:58
Right. Major Payn. I suggest you pop over to the codebase or even to the code snippets and search for the word 'mouse'.

Then study it like mad.

Infra-Dark

Login to post a reply

Server time is: 2025-05-24 23:08:04
Your offset time is: 2025-05-24 23:08:04