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 / keypress detection!!!!!!

Author
Message
James Bond
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location:
Posted: 16th Aug 2004 18:22
#include "c:\func.dba"
make object sphere 1,5
do
if controlkey()=1 then fire_obj(1)
loop

function fire_obj(id)
position object id,0,0,cubePos
cubePos=cubePos + 15
if cubepos > 200 then hide object id
endfunction

My first ever 100% home made code ... with problems
i want the bullet ( sphere ) to fire when i press my Control Key . but with this code the bullet will stop if i release my control key before the bullet hides ... i want the bullet to fire when i press my Control KeY and even if release it that sphere keeps on going untill its cubepos is > 200 ......

TRIED MY BEST TO EXPLAIN THE QUESTION TO YOU
AND I HOPE YOU WILL TRY YOUR BEST TO EXPLAIN THE ANSWER TO ME
MR AI
21
Years of Service
User Offline
Joined: 24th Jan 2004
Location:
Posted: 16th Aug 2004 19:11 Edited at: 16th Aug 2004 19:30
do not read this
MR AI
21
Years of Service
User Offline
Joined: 24th Jan 2004
Location:
Posted: 16th Aug 2004 19:13 Edited at: 16th Aug 2004 19:35
Well see as i miss THAT ANSWER UP
ill try again lol its bin a long night

there is a lot not right here but aleast your trying for your self
respect

ok lets start
MR AI
21
Years of Service
User Offline
Joined: 24th Jan 2004
Location:
Posted: 16th Aug 2004 20:05
The Syntax might not be quite right have not programed on DBC for a long time so you will have to look the Syntax up in the help

we will do it all in the main loop then u can turn it in to a function if u like

make object sphere 1,5 ( thats fine

do

if controlkey()=1 and bulletlife < 0 [ this check to see if the bullet is still active ]

bulletlife=200 [ this give's the range of the bullet ]

[ at this point i will asume that u have pointed the object in
the right direction and positioned it in its start place
]

gosub bullet_move [ call the go sub ]

endif

if bulletlife >0 gosub bullet_move

loop


bullet_move:

bulletlife=bulletlife-5

if bulletlife >0
move object 1,15
endif

if bulletlife < 0 then hide object 1

return


I hope you understand all of this if not just post and i hope it helps good luck

mr A.I
MR AI
21
Years of Service
User Offline
Joined: 24th Jan 2004
Location:
Posted: 16th Aug 2004 20:29
In fact go here

http://darkbasic.thegamecreators.com/?f=tutorials

the one you what is 3d monster hunt ist what i learnt from many year's ago if fact its the only tutorial there was then.

Login to post a reply

Server time is: 2025-05-25 14:02:37
Your offset time is: 2025-05-25 14:02:37