Words Fail Posted January 1 Share Posted January 1 DPC+ kernel so I don't need RAND16. shootmissilebottom rem l=rand if rand<=30 then missile1height=14: missile1x=player1x+10: missile1y=player1y-14: k=1 return thisbank shootmissiletop rem m=rand if rand<=30 then missile0height=14: missile0x=player2x+10: missile0y=player2y+14: n=1 return thisbank If either top or bottom missile is to fire it goes to one of those. I can see the pattern. I fly up, right, up, left, and the first two bullets usually come out at the exact same spots.. I continue to fly around level and I can usually see the bullets in the some of the same spots. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 1 Share Posted January 1 I don't understand what you are trying to do well enough to know why it isn't working as you expected. It doesn't seem like your missile starting location is at all random, but based on the player's position. Quote Link to comment Share on other sites More sharing options...
Words Fail Posted January 2 Author Share Posted January 2 2 hours ago, Karl G said: I don't understand what you are trying to do well enough to know why it isn't working as you expected. It doesn't seem like your missile starting location is at all random, but based on the player's position. Of course it's based on the player (enemy) position. It's a space ship that fires out of the ship. The randomness is to tell if the ship if it should fire or not. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 2 Share Posted January 2 30 minutes ago, Words Fail said: Of course it's based on the player (enemy) position. It's a space ship that fires out of the ship. The randomness is to tell if the ship if it should fire or not. So, the enemy is moving across the screen, and you are noticing that it seems to "randomly" fire when it is in the same place? I follow now, I think. To get more of a feeling of randomness, you can read from rand at times based on the player's actions, so it would presumably be different each time. Basically you are using the player. Something simple like "if joy0fire then temp1=rand" will cycle the random number generator at non-predictable times, and usually lead to a more random-seeming result for when you do use the rand value for something like this. Quote Link to comment Share on other sites More sharing options...
bogax Posted January 2 Share Posted January 2 30 minutes ago, Karl G said: To get more of a feeling of randomness, you can read from rand at times based on the player's actions, so it would presumably be different each time. Basically you are using the player. Something simple like "if joy0fire then temp1=rand" will cycle the random number generator at non-predictable times, and usually lead to a more random-seeming result for when you do use the rand value for something like this. DPC+ uses a better random number generator Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 2 Share Posted January 2 25 minutes ago, bogax said: DPC+ uses a better random number generator It does, but I think my advice to avoid patterns being seen is still valid regardless. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 2 Share Posted January 2 18 hours ago, Words Fail said: DPC+ kernel so I don't need RAND16. shootmissilebottom rem l=rand if rand<=30 then missile1height=14: missile1x=player1x+10: missile1y=player1y-14: k=1 return thisbank shootmissiletop rem m=rand if rand<=30 then missile0height=14: missile0x=player2x+10: missile0y=player2y+14: n=1 return thisbank If either top or bottom missile is to fire it goes to one of those. I can see the pattern. I fly up, right, up, left, and the first two bullets usually come out at the exact same spots.. I continue to fly around level and I can usually see the bullets in the some of the same spots. What happens if you have one that is if rand<31 and the other one that is if rand>224? Does that change the pattern? Quote Link to comment Share on other sites More sharing options...
KevKelley Posted January 2 Share Posted January 2 If you are trying to get an enemy firing but why less discernible pattern sometimes I may do something like have the code for the firing only activate if the enemy was within a certain range of the player. so if the enemy is moving vertically I may look to see if the enemy y coordinates are close to the player y. And if then it may fire. other times I may tie the generation of the random firing to something like a timer or a coordinate of something. I will play around with it and tweak until it just feels right. Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted January 2 Share Posted January 2 I still like to reference R.T.s rand usage charts: https://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#rand A pro game maker move is to seed rand when the player first presses the FIRE button. I do this when they exit the title screen. Since humans are pretty random you're almost sure to get a unique set of numbers coming out of rand. title counter = counter + 1 if joy0fire then rand = counter : goto maingame goto title 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted January 2 Share Posted January 2 (edited) I don't know what DPC+ does but normally if you use rand in the predicate of an if statement it does'nt call the rand function it just references the rand seed/variable Edited January 2 by bogax Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 2 Share Posted January 2 1 hour ago, bogax said: I don't know what DPC+ does but normally if you use rand in the predicate of an if statement it does'nt call the rand function it just references the rand seed/variable Ahh; I didn't realize that, but that's good to know. So, in addition to my advice, I'd suggest @Words Fail try setting a temp variable to rand, and then using the temp variable in the code in question. 1 Quote Link to comment Share on other sites More sharing options...
Words Fail Posted January 2 Author Share Posted January 2 19 hours ago, Karl G said: It does, but I think my advice to avoid patterns being seen is still valid regardless. Your idea sounds good. Quote Link to comment Share on other sites More sharing options...
Words Fail Posted January 2 Author Share Posted January 2 10 hours ago, Random Terrain said: What happens if you have one that is if rand<31 and the other one that is if rand>224? Does that change the pattern? Good idea.. I never thought of that. 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.