You'll need to draw an 82x25 background and save it as an MZM I named mine 'scene1', make sure the ends join
together smoothly. The beauty of this simple system is that it can be added easily to any side scrolling game. It will draw whatever is on the board,
player and all on top of the scenery.
. "--------Scenery 00--------"
put "@scene1.mzm" Image_file p02 at 0 0
set "spr0_vlayer" to 1
set "spr0_refx" to 1
set "spr0_refy" to 0
set "spr0_width" to 80
set "spr0_height" to 25
set "spr0_static" to 1
. "--------Playing Field 01--------"
set "spr1_ccheck" to 2
set "spr1_refx" to 0
set "spr1_refy" to 0
set "spr1_width" to 80
set "spr1_height" to 25
. "Per the tutorial I did, (#13) I split the board in half, using the top half for the playing field and the bottom half for an overlay layer, to appear in"
. "front of the player and objects on the board. If you don't need an overlay layer you can skip this. You cannot use MZX's overlay, for some reason it messes"
". "up this system."
. "--------Fore Ground e7--------"
set "spr231_ccheck" to 2
set "spr231_refx" to 0
set "spr231_refy" to 500
set "spr231_width" to 80
set "spr231_height" to 25
set "local" to "playerx"
put c?? Sprite p00 at 0 0
set "screenpos" to 40
set "screenposy" to 12
: "top"
cycle 1
set "spr1_refx" to "('playerx' - 'screenpos')"
set "spr1_refy" to "('playery' - 'screenposy')"
put c?? Sprite p01 at "('playerx' - 'screenpos')" "('playery' - 'screenposy')"
set "spr231_refx" to "spr1_x"
set "spr231_refy" to "('spr1_y'+('board_h'/2))"
put c?? Sprite pe7 at "('playerx' - 'screenpos')" "('playery' - 'screenposy')"
. "you can change the 6 in the two expressions below to change the rate at which the background scrolls, smaller number for faster scrolling"
if "local" = "('playerx'+6)" then "scroll right"
if "local" = "('playerx'-6)" then "scroll left"
goto "top"
: "scroll left"
copy block at "#0" "#0" for 1 by 25 to "#81" "#0"
copy block at "#1" "#0" for 81 by 25 to "#0" "#0"
copy block at "#0" "#0" for 1 by 25 to "#81" "#0"
set "local" to "playerx"
goto "top"
: "scroll right"
copy block at "#81" "#0" for 1 by 25 to "#0" "#0"
copy block at "#0" "#0" for 81 by 25 to "#1" "#0"
copy block at "#81" "#0" for 1 by 25 to "#0" "#0"
set "local" to "playerx"
goto "top"
if you prefer a static background use this program. The scenery only has to be 80x25 here.
. "--------Scenery 00--------"
put "@scene1.mzm" Image_file p02 at 0 0
set "spr0_vlayer" to 1
set "spr0_refx" to 0
set "spr0_refy" to 0
set "spr0_width" to 80
set "spr0_height" to 25
set "spr0_static" to 1
. "--------Playing Field 01--------"
set "spr1_ccheck" to 2
set "spr1_refx" to 0
set "spr1_refy" to 0
set "spr1_width" to 80
set "spr1_height" to 25
. "--------Fore Ground e7--------"
set "spr231_ccheck" to 2
set "spr231_refx" to 0
set "spr231_refy" to 500
set "spr231_width" to 80
set "spr231_height" to 25
put c?? Sprite p00 at 0 0
set "screenpos" to 40
set "screenposy" to 12
: "top"
cycle 1
set "spr1_refx" to "('playerx' - 'screenpos')"
set "spr1_refy" to "('playery' - 'screenposy')"
put c?? Sprite p01 at "('playerx' - 'screenpos')" "('playery' - 'screenposy')"
set "spr231_refx" to "spr1_x"
set "spr231_refy" to "('spr1_y'+('board_h'/2))"
put c?? Sprite pe7 at "('playerx' - 'screenpos')" "('playery' - 'screenposy')"
goto "top"
if you are making a game with a sprite player character, use this program. you'll need to adjust the screenpos and screenpos_y counters
depending on the size of your player sprite. This one is 3x3. Just place an equivalent sized block in the middle of a 80x25 box and count the
number of blocks from the top left of the player-block to the top left of the screen-square. x=screenpos and y=screenpos_y.
this is with a scationary background. If you want to have a sprite and a scrolling background you can mix the code, or ask me for help,
I don't mind helping
. "--------Scenery 00--------"
put "@scene1.mzm" Image_file p02 at 0 0
set "spr0_vlayer" to 1
set "spr0_refx" to 0
set "spr0_refy" to 0
set "spr0_width" to 80
set "spr0_height" to 25
set "spr0_static" to 1
. "--------Playing Field 01--------"
set "spr1_ccheck" to 2
set "spr1_refx" to 0
set "spr1_refy" to 0
set "spr1_width" to 80
set "spr1_height" to 25
. "--------Fore Ground e7--------"
set "spr231_ccheck" to 2
set "spr231_refx" to 0
set "spr231_refy" to 500
set "spr231_width" to 80
set "spr231_height" to 25
set "screenpos_y" to 11
set "screenpos" to 36
: "top"
cycle 1
. "this expression stops the board from scrolling when you reach the edge, but you'll probably want to add a customblock wall to stop the player too."
if "((('spr&player&_x'<57)o('spr&player&_x'>('board_w'-64))o('spr&player&_y'<46)o('spr&player&_y'>(('board_h'/2)-46)))a('cheat'!=5))" = 1 then "top"
scrollview position "('spr&player&_x'- 'screenpos')" "('spr&player&_y' - 'screenpos_y')"
set "spr1_refx" to "('spr&player&_x' - 'screenpos')"
set "spr1_refy" to "('spr&player&_y' - 'screenpos_y')"
put c?? Sprite p01 at "('spr&player&_x' - 'screenpos')" "('spr&player&_y' - 'screenpos_y')"
set "spr231_refx" to "spr1_x"
set "spr231_refy" to "('spr1_y'+('board_h'/2))"
put c?? Sprite pe7 at "('spr&player&_x' - 'screenpos')" "('spr&player&_y' - 'screenpos_y')"
goto "top"
I would love to see someone else pick this up and use it in their game besides me, let me know if you do.
This post has been edited by Graham: 09 July 2013 - 04:25 AM

Help





