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 / WOW, so much coad, help me cut it down to one line

Author
Message
pc nerd
User Banned
Posted: 12th Apr 2009 08:52
ok, so i have set up my scoring system, it works like a charm, but,to make it work right with some trigger zones i had to put in 50 lines of repeted coad. is there a way to put all this into 2 diffrent lines.



and here is some more in a diffrent aspect



thanks as always

dweeb
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 12th Apr 2009 09:03
Try this.






DBPro, limited by the programmer.
pc nerd
User Banned
Posted: 12th Apr 2009 09:09
well this will work, thank you, i was not shure how to put it, now i will have to change my whole game script to something like this to. but if i do i will have to change it to something else right? like
t is already taken so it will have to be another letter?

dweeb
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 12th Apr 2009 09:37
Nope, as long as they are not inside each other you can use the same letter, I always use t, a lot of other people use i, but it doesn't really matter.


DBPro, limited by the programmer.
pc nerd
User Banned
Posted: 12th Apr 2009 10:08
right,lol, well i have seen this done alot here but was not shure how i would ever use it, now i am,lol.

there is just one problem with it though, it works great but it does not work with negitive numbers, at least not with me.
it did not hold the number i choose, like i put

for E=0 to -1000
if ENERGY#=E
ENERGY#=10
endif
next E

it just cept bumping me into the negitives
-10
-15
so on and so forth.
but hey, you cant win them all

all i did was

if ENERGY#=0
ENERGY#=10
endif

dweeb
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Apr 2009 10:35
Sorry, didn't quite get the last post - what were you trying to achieve and what is Energy# by default?

pc nerd
User Banned
Posted: 12th Apr 2009 10:42 Edited at: 12th Apr 2009 10:42
well, every time i get hit, 10 points of energy is taken from me.
that works great, but when i get to the negatives it does not keep it at 10. i want to make shure it stayes at 10 unless i get more energy wich is 100

it works for the positives well.

dweeb
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 12th Apr 2009 13:40
Err, how about:
If ENERGY#<10 then ENERGY#=10

Why loop for specific numbers?

Applies to the earlier code as well, so:


"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
pc nerd
User Banned
Posted: 12th Apr 2009 22:36
Why loop for specific numbers?

well im usung only increments of ten for my energy, if you have 100 percent energy you move 2.0

but if you have 90 percent energy you move 1.5 so on and so forth all the way down to ten.

ten is the least you can get becouse its range is by ten.

so to make shure it stayes at ten and not bellow is what i was needing. thanks

dweeb
MedianHansen
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 12th Apr 2009 23:36
Personally, i use n, for number ^^
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 13th Apr 2009 00:38
for negetive numbers you need to specify a step value. Like this:



Take a look at the help file for the step command, it might be useful to you.


DBPro, limited by the programmer.
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 13th Apr 2009 00:45
I would point out that DB PROgrammer is using 1000 loops to check something that I did with one instruction.

Guess which is the quicker code!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
pc nerd
User Banned
Posted: 13th Apr 2009 02:09
@ DB PROgrammer , thanks, ill check it, thank you very much.ILL look at the help files for the step command, i had no idea there was one,lol.

@ Dream And Death, where is the coad?

dweeb
pc nerd
User Banned
Posted: 13th Apr 2009 02:31 Edited at: 16th Apr 2009 09:57
edit

dweeb
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 13th Apr 2009 16:01
Ok, pc nerd, the code I was referring to was in my previous posts. I'll try and explain again here.


Does do the job, but loops through 1000 times before it completes.

Whereas:

does the job with one instruction.

Equally well, if all you are worried about is if ENERGY# gets below 1 then:

would also do the job.

There is no reason whatsoever to step through the values, checking each one.

If you are tying in your player's movement speed to their remaining energy, work out the equation that relates the two.

Eg, if they move at SPEED=10 at 100% ENERGY and lose 1 SPEED for each 10% ENERGY then:

would update your player's speed with one line, called once per game loop.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 13th Apr 2009 21:17
Yes, Dream And Death is right, I was just showing you how to use for loops. For loops are very useful and you will want to know how to use them.


DBPro, limited by the programmer.
pc nerd
User Banned
Posted: 13th Apr 2009 22:06
ohh, ok, i know understand, i did not think of it as compleating the loop, as no one will stand there 1000 times to get hit anyway. but i think just in case ill make it a infintint loop.

as far as

SPEED=(ENERGY-100.0)/100.0*10.0+10

this will make my script alot less coad to, thanks for that.

dweeb

Login to post a reply

Server time is: 2024-11-24 08:45:46
Your offset time is: 2024-11-24 08:45:46