ChilePepper Posted April 22, 2020 Share Posted April 22, 2020 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 Quote Link to comment Share on other sites More sharing options...
bogax Posted April 22, 2020 Share Posted April 22, 2020 depends on what you're trying to do this is probably what you want Quote Link to comment Share on other sites More sharing options...
ChilePepper Posted April 23, 2020 Author Share Posted April 23, 2020 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. Quote Link to comment Share on other sites More sharing options...
KevKelley Posted April 23, 2020 Share Posted April 23, 2020 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! Quote Link to comment Share on other sites More sharing options...
ChilePepper Posted April 23, 2020 Author Share Posted April 23, 2020 (edited) 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 April 23, 2020 by ChilePepper Quote Link to comment Share on other sites More sharing options...
bogax Posted April 23, 2020 Share Posted April 23, 2020 (edited) dim p1y = player1y.p ; p is the fractional part if player1y > player0y then p1y = p1y - 0.5 Edited April 23, 2020 by bogax typo 1 Quote Link to comment Share on other sites More sharing options...
ChilePepper Posted April 23, 2020 Author Share Posted April 23, 2020 (edited) 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 April 23, 2020 by ChilePepper Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted April 23, 2020 Share Posted April 23, 2020 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. 2 Quote Link to comment Share on other sites More sharing options...
KevKelley Posted April 23, 2020 Share Posted April 23, 2020 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! Quote Link to comment Share on other sites More sharing options...
+TwentySixHundred Posted April 23, 2020 Share Posted April 23, 2020 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 1 Quote Link to comment Share on other sites More sharing options...
ChilePepper Posted April 23, 2020 Author Share Posted April 23, 2020 (edited) 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 April 23, 2020 by ChilePepper Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 23, 2020 Share Posted April 23, 2020 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: randomterrain.com/atari-2600-memories-batari-basic-commands.html#fixedpoint_p0_p1 There's also an example program: randomterrain.com/atari-2600-memories-batari-basic-commands.html#ex_fixed_point_sprite 2 1 Quote Link to comment Share on other sites More sharing options...
ChilePepper Posted April 23, 2020 Author Share Posted April 23, 2020 Sweet! Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.