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 Professional Discussion / Really, really simple bullet mechanism not working... Please help

Author
Message
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 6th Apr 2011 23:07
Hey all

This is killing me, so I would really deeply appreciate help on this one because I have tried everything in my limited knowledge to get this to work. This isn't a cop out, I want to understand why it's not working, I'd love to have the code provided so that I can see it working but I'm interested to learn not just be provided.

This is what I'm trying to do, a really, really simple "bullet" with the following rules:

1. Bullet must shoot down the line when the 'A' key is pressed
2. Moving the camera should not interfere with the bullets path after 'A' has been pressed.
3. When the bullet hits the wall, it must reset to the cameras position
4. Only one bullet at a time should be released.
5. If the bullet hits an object it must reset to the cameras position.

This is my code so far:


The bullet is object 20 and the camera that I move with the arrow keys is camera 1.

At the moment as soon as the game loads the bullet just runs away, it's not in sync with the camera orientation at all and it doesnt wait for the keystate=1 either.

It does however detect the wall:
but it wont reset to the camera's position after colliding with the wall


I'm at a lost... As I say any help would be great! Thanks in advanced

www.bensimms.co.uk
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Apr 2011 23:20
One thing - you've got the z and y reversed.

the order is

camera position x(), camera position y(), camera position z()

so, unless you are doing that on purpose, you might try changing the order in your code.

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 6th Apr 2011 23:21
Well, the way you wrote that code does the following:

The bullet goes away, and comes back to initial position if that button is pressed.

Assign a value of 1 to a variable like "fire=1"

Then put 'move object' within an area like this:

if fire=1

move object

if collision=1 then fire=0

endif
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 7th Apr 2011 22:04
Ok peeps, @Rich I've put my XYZ in order thanks for pointing that out.



Problem is now, I can look left and right but to move forward and back I have to hold down the 'A' key which fires at the same time. Also holding down 'A' repeatedly fires when I want a one press one fire action. Any pointers, hints?

www.bensimms.co.uk
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 8th Apr 2011 15:26
Still not working, I've tried this now


but still the camera only moves forward when holding down A, but will move left and right... Any advice on what am I doing wrong?

www.bensimms.co.uk

Login to post a reply

Server time is: 2026-07-17 19:13:50
Your offset time is: 2026-07-17 19:13:50