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 / i need help whit the random code

Author
Message
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 22nd Aug 2004 23:23
hi

i need help whit the random code
here is my code for the game:
DONT steal it!



the thing i want is that it goes randome between the inkeys "a" "s" "d"
so when you going to disarm the bomb it switch between the wires so it going to be harder to win

The Nerd

i make games, i play games... But the fun thing is that i like to make them more than play them....
Balid
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 22nd Aug 2004 23:37
the nerd,

Use the scan code number for each key as a test (a = 30, s = 31, d = 32). Use a variable to store the correct wire to cut (red = 30, green = 31, blue = 32).

correctwire = rnd(2) + 30
if scancode() = correctwire
good jod
else
boom
endif

this is not exact code, just an idea.

I hope it helps you find an answer.

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 23rd Aug 2004 00:13
hmmm sorry but can you make a little peace of code were the commands is so i can past it in my other code?

i make games, i play games... But the fun thing is that i like to make them more than play them....
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 23rd Aug 2004 12:16 Edited at: 23rd Aug 2004 12:18
ok firstly to find the scancode run this mini program and press the buttons on the keyboard.

it will tell you the corresponding scancode variable for that particular key.




The next part is how to use them
here is an example



But the structure of your program is going to get real confusing.
I think you should learn how functions work now.

I took your game and made it into functions and changed one of the inkey$ commands to the scancode leaving the other one for you to alter. It took me about 20 minutes to convert it into functions which will save you a tonne of time and headaches.


Have a look at the way i have made your program and tell me if you find that easier to manage.

Try to avoid using gotos as a super last last last resort then dont use gosubs if u can help it and stick with functions.

I also made your game dynamic so each time you run it only one of the wires will deactivate the bomb randomly each time you play it.

sample code works in DBC/DBP



If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 25th Aug 2004 01:39
cheers mate, at least someone appreciates the value invested.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself

Login to post a reply

Server time is: 2025-05-25 09:53:15
Your offset time is: 2025-05-25 09:53:15