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 / prolly a stupid question

Author
Message
max ballwinkle
17
Years of Service
User Offline
Joined: 27th Nov 2006
Location: in a pineapple under the sea
Posted: 25th Apr 2008 19:25
how do i say like walk on a paticular peice of land and it kills me....how will DBP know to kill me if it isnt reading that bit of code?

Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 25th Apr 2008 20:48
That's what loops are for. Generally 60FPS (frames per second, or also loops per second) is good, so unless you are in that place for less than 1/60 of a second, it will read it. For example, a common loop for the main one is a "do loop":



Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 25th Apr 2008 21:25
I think he wants a way in which DBPro will detect the surface beneath the player ... so if he walks on lava or an electric-powered floor, the player will loose health and eventually die ... I want to know this as well ... other engines accomplish this by "texture scanning" so it checks weather the player walks on grass, wood, etc.

Could you help me treat my injured Dino-Fly ?
max ballwinkle
17
Years of Service
User Offline
Joined: 27th Nov 2006
Location: in a pineapple under the sea
Posted: 25th Apr 2008 22:26
it could be done with tiling the ground....but thanks....does it have to read the loop first or can i put it anywhere?

Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 26th Apr 2008 00:38
put the loop anywhere, but inside a LABEL - RETURN wrap ... then call it when needed

Could you help me treat my injured Dino-Fly ?
max ballwinkle
17
Years of Service
User Offline
Joined: 27th Nov 2006
Location: in a pineapple under the sea
Posted: 26th Apr 2008 01:03
so like
gosub Loop
?

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 26th Apr 2008 02:03 Edited at: 26th Apr 2008 22:04
you forgot the return command
heres a working example
BTW don't use loop as a label

[edit] what i meant as like this
bad Idea

max ballwinkle
17
Years of Service
User Offline
Joined: 27th Nov 2006
Location: in a pineapple under the sea
Posted: 26th Apr 2008 03:29
what u mean? 'BTW don't use loop as a label'

pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 26th Apr 2008 07:49
You use an array variable.
Lava or a hot spring affects health.

Read it which attaches a code.

Attachments

Login to view attachments
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 26th Apr 2008 10:35
here's what to do:

main program
bla bla bla
bla bla bla
if something happens then gosub myprog

................................

myprog:

do
bla bla bla
loop

return

Could you help me treat my injured Dino-Fly ?
max ballwinkle
17
Years of Service
User Offline
Joined: 27th Nov 2006
Location: in a pineapple under the sea
Posted: 26th Apr 2008 14:02
im trying to make it so when you push S it will change your cursor to a picture.
IN MAIN LOOP:

out side it


Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 26th Apr 2008 21:36
exactly, put RETURN instead of LOOP ... if you wanna know why, then here's the explanation: when using these commands, always have in mind that they work in groups, independently so DO works only with LOOP like this :

DO

bla bla
bla bla

LOOP

when u do this, the "bla bla" thigs are repeated indefinitely, until you instruct the code inside "bla bla" to end if a specific action is occured ... you can do that with EXIT ... don't use END cause that will terminate the whole program ... now the LABEL (_sicon in your case) works only with RETURN ... the RETURN command makes sure that once the code inside the label has ended, the main program resumes from where the label was called ... so here's a FULL example explaining things:

DO *** this makes the program repeat infinitely if not instructed to stop

bla bla bla
if upkey()=1 then EXIT *** this will exit the loop and continue if there's any code below the loop
if downkey()=1 then END *** this will end the program, no matter how many code would follow under normal conditions
if rightkey()=1 then GOSUB _sicon *** this will pause the loop for the time being, jumping the code to the label specified
bla bla

LOOP *** this will close the loop as it needs to mark the end of it as otherwise, the program would not know which is the actual loop

bla bla
bla bla

_sicon: *** this marks the beginning of the label. please note that when it begins, you have to add ":" as opposed to when you just call it like in the loop above

bla bla bla
if leftkey()=1 then EXIT *** again, this exits the label, but watch what happens next !!!
bla bla bla

RETURN *** because in the command above, you have instructed the program to exit the label, if this RETURN command would not exist, the code would just continue, but instead, because you've added RETURN, the code will jump back in the first loop, resuming work from where it left in the first place

also note that inside the label, you can add other DO LOOP loops, etc. I hope this was helpful

Could you help me treat my injured Dino-Fly ?
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 30th Apr 2008 15:01
Think this ones gone off at a tangent a bit!

Quote: "how do i say like walk on a particular piece of land and it kills me....how will DBP know to kill me if it isn't reading that bit of code?"


Your program will run through each command a step at a time then loop back round to the start and repeat the steps. All of this happens many times a second (60 as noted is good), something like:



So you'll move your player, then it'll check to see if he's on something nasty, then it'll start draining health, then it'll loop back to the start and see if the player has moved again, if not is he still on something nasty, if so it'll drain a bit of health, etc, etc until you move your player off the nasty patch or he dies.

Your game will likely run in a small game loop which calls all the other functions and sub-routines. You want to minimise the number of loops (for/nexts, repeat/untils, etc) that aren't in your main loop to keep the speed up. The computer only reads one bit at a time (just very fast).

There's lots of ways you can determine what the player is standing on such as is he within a certain x,y,z boundary, cast a collision ray beneath the player and assign specific object groups (or individual objects) to different rates of health drain, is the player over a particular colour, does he collide with a particular sprite range.

Login to post a reply

Server time is: 2024-11-25 03:46:02
Your offset time is: 2024-11-25 03:46:02