ioi_xd Posted April 23, 2018 Share Posted April 23, 2018 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.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? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 23, 2018 Share Posted April 23, 2018 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 Quote Link to comment Share on other sites More sharing options...
bogax Posted April 23, 2018 Share Posted April 23, 2018 (edited) or ; rand & 3 will be a random number 0..3 if collision(player0, missile1) then d = rand & 3 : player0x = P0xrnd[d] : player0y = P0yrnd[d] data P0xrnd 80, 140, 85, 10 end data P0yrnd 10, 50, 90, 50 end Edited April 23, 2018 by bogax 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.