Jump to content
Sign in to follow this  
Captain Spazer

Control over randomized playfield?

Recommended Posts

I'm experimenting with a randomly generated horizontal scrolling playfield, trying to make something like the levels in the Game & Watch version of Super Mario Bros, it works but it's way to random, and I was hoping someone had some tips on how to store premade parts of the playfield that could be choosen and placed at random as the level scrolls in.

My code so far simply involves turning pfpixels on at points where the ground and blocks should be:
 


 a = 0

 player0x = 20 : player0y = 72

main
 COLUBK=$00
 COLUPF=$0E
 COLUP0=$44
 scorecolor = $0E


 player0:
 %01100110
 %00100100
 %01011010
 %00111100
 %00011000
 %00011100
 %00011000
 %00000000
end


 rem spawns a row at lowest level
 if a = 0 then  pfpixel 31 10 on

 rem spawns blocks at highest level
 if a = 1 then  pfpixel 31 2 on

 rem spawns blocks at middle level
 if a = 2 then  pfpixel 31 6 on

 if a = 3 then pfpixel 31 6 on : pfpixel 31 10 off : pfpixel 31 2 off

 drawscreen

 rem scrolls playfield
 b = b + 1
 if b = 1 then pfscroll left
 if b >= 31 then b = 0

 c = c + 1
 if c = 60 then a = (rand&3)
 if c = 61 then c = 0

 goto main

 

Share this post


Link to post
Share on other sites

I kind of figured out a way to do it, making pretty good mario styled platforming sections with good holes and some higher platforms in the sky. With enough pieces a randomly generated mario platformer would be doable:

 

 rem Generated 26/04/2020 12:55:57 by Visual bB Version 1.0.0.554
 rem **********************************
 rem *<filename>                      *
 rem *<description>                   *
 rem *<author>                        *
 rem *<contact info>                  *
 rem *<license>                       *
 rem **********************************


 a = 0

 player0x = 20 : player0y = 72

main
 COLUBK=$00
 COLUPF=$0E
 COLUP0=$44
 scorecolor = $0E


 player0:
 %01100110
 %00100100
 %01011010
 %00111100
 %00011000
 %00011100
 %00011000
 %00000000
end

 rem starting with full row of blocks on ground
 if a = 0 then var40=%11111111 : var41=%11111111 : var42=%11111111 : var43=%11111111 : var20=%00000000 : var21=%00000000 : var22=%00000000 : var23=%00000000 : a = 5

 rem spawns a row at lowest level
 if a = 1 then var40=%11111111 : var41=%11111111 : var42=%11111111 : var43=%00000011 : var20=%00000000 : var21=%00000000 : var22=%00000000 : var23=%00000000 : a = 5

 rem air platforms
 if a = 2 then var40=%11111111 : var41=%11111111 : var42=%11111111 : var43=%00001111 : var20=%00000000 : var21=%00000000 : var22=%00000000 : var23=%11000000 : a = 5

 if a = 3 then var40=%11111111 : var41=%11111111 : var42=%11111111 : var43=%00001111 : var20=%00000000 : var21=%00000000 : var22=%00000000 : var23=%11110000 : a = 5

 drawscreen

 rem scrolls playfield
 b = b + 1
 if b = 1 then pfscroll left left
 if b >= 10 then b = 0
 c = c + 1
 if c = 255 then a = (rand&3) : c = 0

 goto main

 

  • Like 1

Share this post


Link to post
Share on other sites

You might want to take a look at how Pitfall did it.  @Thomas Jentzsch's disassembly of it can be found at minidig.

 

; Scene generation:
; The 255 scenes are randomly generated through a "bidirecional" LFSR. This
; means, that the process of generating the next random number is reversible,
; which is necessary to allow traveling though the jungle in both directions.
; The random number defines the scene with the following bits:
; - 0..2: type of object(s) on the ground (logs, fire, cobra, treasure etc.)
; - 3..5: type of scene (holes, pits, crocdiles, treasures etc.)
; - 6..7: type of the tree pattern
; - 7   : position of the wall (left or right)

 

 

 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

I feel like the Atari needs some more platformers. Excited to see what you come up with. 

  • Thanks 1

Share this post


Link to post
Share on other sites

Would be neat, yeah. I got a basic engine going: Jump on enemies, breaking blocks, walking, jumping, running and super jumping.

I need to figure out how to do better platforming enemies as for now they can't detect walls and that makes things tricky when there are holes in the ground, heh.

Share this post


Link to post
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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...