Jump to content
IGNORED

Randomly Appearing Ball


esplonky

Recommended Posts

I want to make a ball appear at a random time in a random place, then disappear once the player0 touches and then repeat. right now, i have an affixed time and place for the ball to appear by doing this:

 

 

 

f = f + 1

if f = 100 then ballx = 47
if f = 100 then bally = 35

if collision(player0,ball) then f = 0

if f = 0 then ballx = 200
if f = 0 then bally = 200

 

how do I:

 

1. make it take longer to appear

2. randomize location without it going out of bounds

3. make it make the player move faster for 5 seconds after it was touched

Edited by esplonky
Link to comment
Share on other sites

Time in seconds are variables of 60. For example: 2 seconds would be 120, 3 seconds would be 180, and 4 seconds would be 240. (bB numbers don't go above 255.) It depends on how long you would want it to appear. For more than 5 seconds, you could do this (which would have to use another variable):

g=g+1
if g>59 then g=0 : f=f+1
if f=6 then f=0 : ballx=(rand/2)+20 : bally=(rand/4)+20

The above code is for 6 seconds. For five seconds, you would just reduce the part "if f=6" to "if f=5".

To make it make the player move faster after it was touched, you could do something like this:

if collision(player0,ball) then j{0}=1 : bally=100 : h=1 else h=2 : j{0}=0
i=i+1
if i>h && joy0left && player0x>20 then player0x=player0x-1
if i>h && joy0right && player0x<140 then player0x=player0x+1
if i>h && joy0up && player0y>20 then player0y=player0y-1
if i>h && joy0down && player0y<88 then player0y=player0y+1
if i>h then i=0

Edited by atari2600land
  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...