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 / Can't shoot bullets (DBPro n00b)

Author
Message
p1tch
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 3rd Mar 2010 18:40
Hello fellow DarkBasicPro coders.
I have started my first game in Dbpro.It's a simple asteroid like top view shooter.But i have a problem.
I used a shootin snippet modified a bit for my code.But it doesn't shoot.Can some one check my cod and see whats wrong ?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th Mar 2010 16:04
You never call the function MoveMissiles() in your main loop. Put that in and it should work.

p1tch
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 4th Mar 2010 17:06
Ok called called the function MakeModels()
but i get the error "Object already exists at line 113"
Line 113 is

Which is in my MakeModels function.Strange ...
p1tch
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 4th Mar 2010 17:21
Oops.My bad .Ignore my last post.Everyhing now works fine
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 8th Mar 2010 02:10
You did it right but just for someone else to learn from this,i can say that this error is produced because you forget to inc m variable each time the function is called.

Where there is a will, there is a way.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 8th Mar 2010 02:35
Quote: "You did it right but just for someone else to learn from this,i can say that this error is produced because you forget to inc m variable each time the function is called."


What exactly are you talking about luskos? The problem was caused by his missiles being placed off screen and were not moved, so you never saw them. By including the MoveMissile() function call in his do - loop, you can now see them. Problem solved, as he said
Quote: "Everyhing now works fine "


He is moving all five missiles (TotalMissiles) every loop. I don't see where you are coming from.

p1tch
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 8th Mar 2010 19:09
Luskos,you can use the code i posted and use it
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Mar 2010 04:30 Edited at: 9th Mar 2010 04:37
Why oh why can't people indent code properly these days?

It looks so much tidier, makes code ten times easier to read and saves loads of time when trying to track down nesting errors.

"Good indentation and plentiful, meaningful comments are often more important than the code itself". That's what I was taught when I started to program over thirty years ago. It's still true now, but newcomers just don't seem to be bothered.

It's not like it's all that difficult...

I have to admit that this one is a lot better than many you see, but it looks like you gave up half way through.

Maybe I'm just turning into a grumpy old man...

TDK

Login to post a reply

Server time is: 2024-11-24 20:42:56
Your offset time is: 2024-11-24 20:42:56