Jump to content
IGNORED

What's the best way to execute a random event?


ioi_xd

Recommended Posts

I'm trying to make it so then when I shoot the enemy object, it respawns at a random part of the map in a different color. I got the color thing set, but I have one problem: Due to the way the playfield is set up, I can only have the player come out from four specified areas of the map.

6nE21fp.png

I have worked out some code using "rand", but it doesn't seem to be working.

 d = 0

 [...]

 if collision(player0,missile1) then d = rand
 if rand < 4 then d = 4

 if d = 1 then player0x = 80 : player0y = 10
 if d = 2 then player0x = 140 : player0y = 50
 if d = 3 then player0x = 85 : player0y = 90
 if d = 4 then player0x = 10 : player0y = 50

The missile doesn't seem to even affect the enemy, it just goes right through it.

Any idea on what I can do?

Link to comment
Share on other sites

You might want to do it like this instead:


   if !collision(player0,missile1) then goto __Skip_Respawn

   temp5 = rand

   if temp5 < 65 then then player0x = 80 : player0y = 10
   if temp5 > 64 && temp5 < 129 then player0x = 140 : player0y = 50
   if temp5 > 128 && temp5 < 193 then player0x = 85 : player0y = 90
   if temp5 > 192 then player0x = 10 : player0y = 50

__Skip_Respawn
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...