IGNORED

# numbers...

## Recommended Posts

heya folks. I was just wandering how to wright numbers with decimals such as 0.5, 2.6, 3.4 etc. Any help would be appreciated

##### Share on other sites

depends on what you're trying to do

##### Share on other sites

here is an example:

You know the tinkernut tutorial, right? That has you making a game in which a squirrel-thing chases a nut thing. to make the squirrel move you would use some lines of code like

if player1y > player01 then player1y = player1y -1

how would I make it so that it would be like "then player1y = player1y - 0.5" aka, slowing down the squirrel. Help is appreciated. Thanks.

##### Share on other sites

Definitely check the link provided as it is a big help. Basically you have to define a special variable, so do something like :

dim squirrelthing_move = a.b

Then you define a and b.

So a=0 and b=5

So you can do this:

if player1y > player01 then player1y = player1y -squirrelthing_move

But if you are really interested in learning, I highly recommend reading the forums and Random Terrain's website. There is a lot of helpful information out there!

##### Share on other sites

uh oh, now its not moving period.

a = 0
b = 5
dim slowspeed = a.b

if player1y < player0y then player1y = player1y + slowspeed
if player1y > player0y then player1y = player1y - slowspeed
if player1x < player0x then player1x = player1x + slowspeed
if player1x > player0x then player1x = player1x - slowspeed

once again, thanks for the help

Edited by ChilePepper
##### Share on other sites

```  dim p1y = player1y.p  ; p is the fractional part

if player1y > player0y then p1y = p1y - 0.5
```
Edited by bogax
typo
##### Share on other sites

Okay, so bogax's thing worked, except the speed of the squirrel seemed to change randomly, sometimes going painfully slow, sometimes turbo speed. How would I fix this? thanks for the 4th time.

Edited by ChilePepper
##### Share on other sites

50 minutes ago, KevKelley said:

Definitely check the link provided as it is a big help. Basically you have to define a special variable, so do something like :

dim squirrelthing_move = a.b

Then you define a and b.

So a=0 and b=5

So you can do this:

if player1y > player01 then player1y = player1y -squirrelthing_move

But if you are really interested in learning, I highly recommend reading the forums and Random Terrain's website. There is a lot of helpful information out there!

This would not work, it would only add a to player1y, and in this case it's 0 so nothing would happen,

and I don't think 0.5 sets b to five, probaly 128 or something.

##### Share on other sites

Thanks. I knew I should double check! I was feeling brave enough to post something from memory. This reinforces my statement about reading the website!

##### Share on other sites

7 hours ago, ChilePepper said:

Okay, so bogax's thing worked, except the speed of the squirrel seemed to change randomly, sometimes going painfully slow, sometimes turbo speed. How would I fix this? thanks for the 4th time.

Using this method you will need to add a statement for when player1 is less then player0, add this aswell

`if player1y < player0y then p1y = p1y + 0.5`

Im assuming what you're experiencing is when your player is above player1 it goes full speed

As for the speed being too slow - you will need to tweak the value as desired

##### Share on other sites

this is what i got:

dim p1y = player1y.p
dim p1x = player1x.p

if player1y < player0y then p1y = p1y + 0.5
if player1y > player0y then p1y = p1y - 0.5
if player1x < player0x then p1x = p1x + 0.5
if player1x > player0x then p1x = p1x - 0.5

still moving slow and fast and stufff. Thanks.

Edited by ChilePepper
##### Share on other sites

You are reusing the same variable. Try something like this instead:

```   dim p1y = player1y.p
dim p1x = player1x.o```

Here's an example on the bB page:

There's also an example program:

• 2
• 1
##### Share on other sites

Sweet! Thank you!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.