esplonky #1 Posted June 22, 2012 (edited) I need a way to randomize a scrolling playfield, but like a cave sort of scene, so as you move to the right, the playfield makes random ridges on the top and bottom of the screen and then a few blocks in the middle area. and i would like collision detection too Edited June 22, 2012 by esplonky Quote Share this post Link to post Share on other sites
+Gemintronic #2 Posted June 22, 2012 (edited) If it's just random screens look at my Destiny source here: http://www.atariage....p/#entry2140266 I divide the playfield into three horizontal chunks. When I randomly select one chunk I push up the screen using pfmove commands then randomly select another chunk and repeat the process until all 3 sections have filled the screen. The problem is, you want a scrolling game with random screens. In that case I'd just make and destroy random blocks in the corners that are about to move off screen. So, if you're moving left randomly make and destroy blocks to the far right. Edited June 22, 2012 by theloon Quote Share this post Link to post Share on other sites
esplonky #3 Posted June 22, 2012 and how can that be achieved? Quote Share this post Link to post Share on other sites
+Gemintronic #4 Posted June 22, 2012 (edited) This is off the cuff, but, I think random playfield blocks can be placed with the pfpixel command. Work that PFPIXEL command boy! pfpixel xpos ypos function ( | ) xpos can be 0-31 and ypos can be 0-11 (11 is hidden off of the screen and only seen if scrolled.) If you use Superchip RAM and pfres, you can have more than 11 rows. function is any of on, off, or flip. On turns the block on, off turns it off, and flip turns it off if it was on or on if it was off. Basically, if you needed to scramble the far left-hand side of the cave you'd do a few pfpixel commands: pfpixel 0 (rand&3) flip pfpixel 0 (rand&3) flip pfpixel 0 (rand&3) flip ..and so on. The rand&3 part is to get a number between 0 and 3. UPDATE: You'd want to update a small column of blocks to the left (when moving right) so I switched "(rand&3) 0" to "0 (rand&3)" Edited June 22, 2012 by theloon Quote Share this post Link to post Share on other sites
esplonky #5 Posted June 22, 2012 (edited) ah ok Edited June 22, 2012 by esplonky Quote Share this post Link to post Share on other sites
esplonky #6 Posted July 23, 2012 Can i get a code snippet (With Comments explaining what it's doing) Quote Share this post Link to post Share on other sites
+Gemintronic #7 Posted July 23, 2012 Can i get a code snippet (With Comments explaining what it's doing) I'm not ignoring you dawg I'm behind on my own coding (my own fault). Hopefully someone will whip up or link to a good example. Quote Share this post Link to post Share on other sites
esplonky #8 Posted July 24, 2012 Yeah, That's how I've learned how to code in bB pretty much, is code snippets Quote Share this post Link to post Share on other sites
+Gemintronic #9 Posted July 26, 2012 (edited) rem Compiler Options set smartbranching on set romsize 4k rem These are basic settings for a simple game. smartbranching never hurts. We don't need multi-bank so 4k. rem Declare variables dim xpos = a dim ypos = b rem bB doesn't always work right with temp variables and doesn't like alot of caclulations on one line. We're gonna use up two variables for the playfield pixel position. rem Startup code init COLUPF = $0E rem Put code here that should always run before the main program begins. In this case I'm setting the playfield pixel color to white. rem Main loop main xpos = rand&3 ypos = rand&3 pfpixel xpos ypos flip drawscreen goto main rem Like I said, bB wont let us do pfpixel temp1 temp2 or lots of calculations like pfpixel 0 (rand&3) flip so we have to break it down. Edited July 26, 2012 by theloon Quote Share this post Link to post Share on other sites
Mr SQL #10 Posted July 26, 2012 Can i get a code snippet (With Comments explaining what it's doing) I'm not ignoring you dawg I'm behind on my own coding (my own fault). Hopefully someone will whip up or link to a good example. esplonky, here is a block of code I think you may enjoy The routine draws several layers of random structures over one another to create a random cityscape. v=5 rem overlay 5 drawings of random structures, try setting it to 1 to see the difference for w=1 to v q = rand: q= q / 8 rem q = 32 - q if q < 5 then q = 5 if q >26 then q = 6 t= rand: t= t/8 u = rand: u= u/40 + t rem can't get that last column... so don't set it if u>29 then u=29 if t>29 then t=29 for m = t to u for n = q to 31 rem goes to 31 pfpixel m n on next next next Quote Share this post Link to post Share on other sites
+Gemintronic #11 Posted July 26, 2012 (edited) @Mr SQL: I can't get your code to work right. Doesn't compile as is. Could to provide a yaddayadda.bas file instead? UPDATE: Thank you Mr SQL Edited July 26, 2012 by theloon Quote Share this post Link to post Share on other sites
Mr SQL #12 Posted July 26, 2012 @Mr SQL: I can't get your code to work right. Doesn't compile as is. Could to provide a yaddayadda.bas file instead? loon, sure the example is from CityScape, I've shared the source code here: http://www.atariage.com/forums/topic/187460-cityscape-new-2600-game/ I have an idea why the block isn't compiling for you; try setting the option for a 31 pfpixel high screen (superchip) instead of 11 pfpixels: set romsize 8kSC const pfres=32 Quote Share this post Link to post Share on other sites
esplonky #13 Posted July 27, 2012 @theloon is yours just supposed to be white blocks moving around up in the top left? Quote Share this post Link to post Share on other sites
+Gemintronic #14 Posted July 27, 2012 (edited) @theloon is yours just supposed to be white blocks moving around up in the top left? Ya man! rand&3 gives a random number between 0 and 3. I give the variables xpos (hortizontal playfield position) and ypos (vertical playfield position) a number between 0 and 3. I then use the pfpixel command with those xpos and ypos to place a playfield pixel. When I specifiy flip it reverses whatever piayfield pixel is at that location. Edited July 27, 2012 by theloon Quote Share this post Link to post Share on other sites