Author Topic: Peek at my Super Mario clone  (Read 4481 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Peek at my Super Mario clone
« on: September 06, 2019, 12:17:08 pm »
Early in production, you can see how Mario moves, I still need to add the slide frame to his animation but I think I have the 'feel' correct. and you can run through the first level(aka World 1-1) but you will notice he is floating, I tweeked the background and haven't adjusted its Y position yet. But I do know about it and will probably fix it right after posting this. Been having a hard time getting into my programing grove and thought I might just try and force myself to do something little(like posting a sample). those few weeks of being stuck on my arse not able to do much(or anything) really took it out of me even though I tried to stay as active, programing wise, as I could.

but anyway here is a sample peek at my Mario clone (NES version):
Left and Right arrows to move(just like in the real game it will scroll right but not left)

preliminary jumping is now active, jump as high as you like by holding down the space bar(until I add the limit check anyway)

and ESC to quit, although reaching the pole will quit too. and do not worry, there is no collision checking or gravity(obviously) yet.
like I said 'very' early in production. Hoping to get Mario jumping soon
Code: QB64: [Select]
  1. TYPE PlayerData
  2.  Yloc AS INTEGER
  3.  Score AS _UNSIGNED LONG
  4.  Facing AS _BYTE
  5.  Action AS INTEGER 'bit flags for action: walking R\L, Running R\L, Jumping, Crouching, Spitting Fireball
  6.  '                  0 W/R, 1 W/L, 2 R/R, 3 R/L, 4 Jmp, 5 Crch, 6 SptFB, 7 mvng R pressing L
  7.  '                  8 mvng L pressing R, 9 mvng R Crch, 10 mvng L Crch, 11 Mvng R Jmping, 12 Mvng L Jmping
  8.  '                  will require _SETBIT, _READBIT, and _TOGGLEBIT
  9.  
  10. TYPE GameData
  11.  Player1Level AS _BYTE
  12.  Player2level AS _BYTE
  13.  TimeLeft AS _UNSIGNED _BYTE
  14.  GlobalX AS _UNSIGNED INTEGER
  15.  Movement AS SINGLE
  16.  Jump AS _BYTE
  17. TYPE MapData
  18.  Sprite AS _BYTE
  19.  typ AS _BYTE
  20. TYPE TileData
  21.  Sprite AS _BYTE
  22.  Typ AS _BYTE
  23.  Special AS _BYTE 'how long a multicoin block is active, also doubles as warp location ID
  24. TYPE EnemyData
  25.  Sprite AS _BYTE
  26.  Typ AS _BYTE
  27.  
  28. 's = s0 + v * t + 1 / 2 * a*t^2
  29.  
  30. CONST TRUE = -1, FALSE = 0, Decel = INT(.75 * 4 / (28) * 10000) / 10000
  31. CONST Right = 19712, Left = 19200, Up = 18432, Down = 20480, A_button = 32, B_Button = 13, Start_Button = 65
  32. CONST Air = 0, Blocking = 1, Coin = 2, PowerUP = 3, Star = 4, MultiCoin = 5, Breakable = 6, Vine = 7
  33. CONST Warp = 8, XtraLife = 9
  34. CONST Still = 0, Walk_right = 1, Run_Right = 2, Walk_left = 3, Run_Left = 4, Crouch = 5, Jump = 6
  35.  
  36. CONST MaxMovement = 4, Max_Jump_Height = 140, Gravity = .125, InitalJump = 4
  37.  
  38. SCREEN _NEWIMAGE(640, 480, 32)
  39. DIM SHARED Player(1) AS PlayerData, G AS GameData
  40. DIM SHARED Blocks(14, 240) AS MapData, Tiles(1600) AS TileData, Pipes(16) AS TileData
  41. DIM SHARED Enemys(32) AS EnemyData
  42. DIM MovementFlag AS _BYTE
  43. DIM SHARED Layer(8) AS LONG, Level AS LONG, Mario AS LONG
  44.  
  45. INIT
  46.  
  47. Layer(0) = _DISPLAY
  48. Layer(1) = _NEWIMAGE(640, 480, 32)
  49.  
  50. Build_Premap_Background Layer(2), Layer(4), 1
  51. Build_Premap_Blocks Layer(3), Layer(4), 1
  52. 'OPEN "Level1_1.dat" FOR BINARY AS #1
  53. 'PUT #1, , Blocks()
  54. 'PUT #1, , Tiles()
  55. 'PUT #1, , Pipes()
  56. 'PUT #1, , Enemys()
  57. 'CLOSE #1
  58. 'move prebuild map to full final
  59. _PUTIMAGE (0, 0)-STEP(7679, 479), Layer(4), Level, (0, 0)-STEP(3839, 239)
  60.  
  61. 'FOR i% = 0 TO 3088 STEP 4
  62. '_PUTIMAGE (64, 0)-STEP(511, 447), Level, Layer(1), (0 + i% * 2, 16)-STEP(511, 447)
  63. '_PUTIMAGE (64, 0)-STEP(512, 448), Layer(5), Layer(1), (0 + i%, 8)-STEP(255, 223)
  64. '_PUTIMAGE , Layer(1), Layer(0)
  65. '_DELAY .05
  66. 'LOCATE 1, 1: PRINT i%
  67. 'IF INKEY$ = CHR$(27) THEN i% = 4000
  68. 'NEXT i%
  69.  
  70. 'END
  71. ExitFlag%% = FALSE
  72. G.Movement = 1
  73.  Movement_Logic Player(0).Xloc, Player(0).Yloc, LastDirection%%
  74.  
  75.  IF _KEYHIT = 27 THEN ExitFlag%% = TRUE
  76.  IF G.GlobalX >= 6070 THEN ExitFlag%% = TRUE
  77.  
  78.  Display_Current_Level_Section Level, Layer(1), G.GlobalX
  79.  IF G.Jump THEN Action%% = Jump ELSE Action%% = LastDirection%%
  80.  Display_Mario_Action Mario, Layer(1), Player(0).Xloc, Player(0).Yloc, Action%%, small
  81.  
  82.  _PUTIMAGE , Layer(1), Layer(0)
  83.  LOCATE 1, 1: PRINT Player(0).Xloc
  84.  PRINT Player(0).Yloc
  85.  PRINT G.GlobalX
  86.  PRINT G.Movement
  87.  PRINT G.Jump
  88.  
  89.  _DELAY .0167
  90. LOOP UNTIL ExitFlag%%
  91.  
  92. SUB Display_Current_Level_Section (From&, Where&, Xoff~%)
  93.  _PUTIMAGE (64, 0), From&, Where&, (0 + Xoff~%, 16)-STEP(511, 447)
  94.  
  95. SUB Display_Mario_Action (From&, Where&, Xoff%, Yoff%, Action%%, Size%%)
  96.  STATIC Frame AS _BYTE, SubFrame AS _BYTE, LastDirection AS _BYTE
  97.  
  98.  SELECT CASE Action%%
  99.   CASE Walk_right
  100.    _PUTIMAGE (64 + Xoff%, 368), From&, Where&, (2 + (Frame * 34), 2)-STEP(31, 31)
  101.    SubFrame = SubFrame + 1
  102.    IF SubFrame = 6 THEN Frame = Frame + 1: SubFrame = 0
  103.    IF Frame = 4 THEN Frame = 1
  104.   CASE Walk_left
  105.    _PUTIMAGE (64 + Xoff% + 31, 368)-STEP(-31, 31), From&, Where&, (2 + (Frame * 34), 2)-STEP(31, 31)
  106.    SubFrame = SubFrame + 1
  107.    IF SubFrame = 6 THEN Frame = Frame + 1: SubFrame = 0
  108.    IF Frame = 4 THEN Frame = 1
  109.   CASE Jump 'jumping
  110.    IF Action%% = M_left THEN
  111.     _PUTIMAGE (64 + Xoff% + 31, 368 - Yoff%)-STEP(-31, 31), From&, Where&, (2 + (5 * 34), 2)-STEP(31, 31)
  112.    ELSE
  113.     _PUTIMAGE (64 + Xoff%, 368 - Yoff%), From&, Where&, (2 + (5 * 34), 2)-STEP(31, 31)
  114.    END IF
  115.   CASE Run_Right
  116.    _PUTIMAGE (64 + Xoff%, 368), From&, Where&, (2 + (Frame * 34), 2)-STEP(31, 31)
  117.    SubFrame = SubFrame + 1
  118.    IF SubFrame = 4 THEN Frame = Frame + 1: SubFrame = 0
  119.    IF Frame = 4 THEN Frame = 1
  120.   CASE Run_Left
  121.    _PUTIMAGE (64 + Xoff% + 31, 368)-STEP(-31, 31), From&, Where&, (2 + (Frame * 34), 2)-STEP(31, 31)
  122.    SubFrame = SubFrame + 1
  123.    IF SubFrame = 4 THEN Frame = Frame + 1: SubFrame = 0
  124.    IF Frame = 4 THEN Frame = 1
  125.   CASE Still
  126.    IF LastDirection THEN DX%% = -31: SX%% = 31 ELSE DX%% = 31: SX%% = 0
  127.    _PUTIMAGE (64 + Xoff% + SX%%, 368)-STEP(DX%%, 31), From&, Where&, (2, 2)-STEP(31, 31)
  128.    Frame = 1: SubFrame = 0
  129.  
  130. SUB Movement_Logic (Xloc~%, Yloc%, Action%%)
  131.  STATIC Height AS INTEGER, Velocity AS SINGLE
  132.  IF _KEYDOWN(Right) THEN G.Movement = G.Movement + .1: Action%% = Walk_right
  133.  IF _KEYDOWN(Left) THEN G.Movement = G.Movement - .1: Action%% = Walk_left
  134.  IF _KEYDOWN(A_button) THEN G.Jump = TRUE: Velocity = InitalJump
  135.  
  136.  IF (NOT _KEYDOWN(Right)) AND (NOT _KEYDOWN(Left)) THEN
  137.   IF G.Movement > 0.2 THEN
  138.    G.Movement = G.Movement - .1
  139.   ELSEIF G.Movement < -0.2 THEN
  140.    G.Movement = G.Movement + .1
  141.   ELSE
  142.    G.Movement = 0: Action%% = Still
  143.   END IF
  144.  
  145.  LOCATE 10, 1: PRINT Height
  146.  PRINT Velocity
  147.  IF G.Movement > MaxMovement THEN G.Movement = MaxMovement
  148.  IF G.Movement < (-MaxMovement) THEN G.Movement = (-MaxMovement)
  149.  Xloc~% = Xloc~% + G.Movement
  150.  Yloc% = Height
  151.  
  152.  IF G.Jump THEN
  153.   Height = Height + Velocity
  154.   Jump_Frame = Jump_Frame + 1
  155.   Velocity = Mushroom_Drag(Velocity, Jump_Frame)
  156.  IF Height < 0 THEN G.Jump = 0: Jump_Frame = 0: Height = 0
  157.  
  158.  IF Xloc~% < 4 THEN Xloc~% = 4: G.Movement = 0
  159.  IF Xloc~% > 256 THEN Xloc~% = 256: G.GlobalX = G.GlobalX + G.Movement
  160.  
  161. SUB Build_Premap_Background (From&, Where&, level%%)
  162.  FOR i%% = 0 TO 4
  163.   _PUTIMAGE (768 * i%%, 0), From&, Where&
  164.  NEXT i%%
  165. ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  166.  
  167. SUB Build_Premap_Blocks (From&, Where&, level%%)
  168.  'level 1, non passable\non breakable blocks
  169.  DATA ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,1,1,1,1,1,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  184.  FOR j%% = 0 TO 14
  185.   FOR I~%% = 0 TO 239
  186.    READ Blocks(j%%, I~%%).Sprite
  187.    IF Blocks(j%%, I~%%).Sprite <> 0 THEN Blocks(j%%, I~%%).typ = Blocking
  188.    Draw_Block Blocks(j%%, I~%%).Sprite, I~%% * 16, j%% * 16, 16, From&, Where&
  189.   NEXT I~%%
  190.  NEXT j%%
  191.  'level 1, Breakable\coin blocks as X,Y, sprite id, typ(2-coin block,3-shrum\flower,4-star,5-multicoin,6-breakable,7-vine,9-Xtralife)
  192.  DATA 44,17,9,8,2,21,9,5,6,22,9,8,3,23,9,5,6,24,9,8,2,25,9,5,6,23,5,8,2,65,9,0,9,77,9,5,6,78,9,8,3,79,9,5,6,80,5,5,6,81,5,5,6,82,5,5,6,83,5,5,6,84,5,5,6,85,5,5,6,86,5,5,6,87,5,5,6
  193.  DATA 90,5,5,6,91,5,5,6,92,5,5,6,93,5,8,2,93,9,5,5,99,9,5,6,100,9,8,4,105,9,8,2,108,9,8,2,111,9,8,2,108,5,8,3,117,9,5,6,120,5,5,6,121,5,5,6,122,5,5,6,127,5,5,6
  194.  DATA 128,5,8,2,129,5,8,2,130,5,5,6,128,9,5,6,129,9,5,6,168,9,5,6,169,9,5,6,170,9,8,2,171,9,5,6
  195.  READ TileCount%
  196.  FOR I% = 0 TO TileCount% - 1
  197.   READ Tiles(I%).Xloc
  198.   Tiles(I%).Xloc = Tiles(I%).Xloc - 1
  199.   READ Tiles(I%).Yloc
  200.   READ Tiles(I%).Sprite
  201.   READ Tiles(I%).Typ
  202.   Draw_Block Tiles(I%).Sprite, Tiles(I%).Xloc * 16, Tiles(I%).Yloc * 16, 16, From&, Where&
  203.  NEXT I%
  204.  
  205.  'level 1 pipe location and height as X,Y,H,Warp? 1st-#of
  206.  DATA 6,28,12,1,0,38,12,2,0,46,12,3,0,57,12,3,8,163,12,1,0,179,12,1,0
  207.  READ PipeCount%
  208.  FOR I% = 0 TO PipeCount% - 1
  209.   READ Pipes(I%).Xloc
  210.   READ Pipes(I%).Yloc
  211.   READ Pipes(I%).Sprite 'used for height in pipes
  212.   READ Pipes(I%).Typ
  213.   Draw_Pipe Pipes(I%).Sprite, Pipes(I%).Xloc, Pipes(I%).Yloc, From&, Where&
  214.  NEXT I%
  215.  
  216.  'level 1 enemy location and type X,Y,type,heading
  217.  DATA 17,352,192,1,1,640,192,1,1,816,192,1,1,840,192,1,1,1264,64,1,1,1296,64,1,1,1536,192,1,1,1560,192,1,1
  218.  DATA 1696,186,2,1,1824,192,1,1,1848,192,1,1,1984,192,1,1,2008,192,1,1,2048,192,1,1,2072,192,1,1
  219.  DATA 2784,192,1,1,2808,192,1,1
  220.  READ EnemyCount%
  221.  FOR I% = 0 TO EnemyCount% - 1
  222.   READ Enemys(I%).Xloc
  223.   READ Enemys(I%).Yloc
  224.   READ Enemys(I%).Sprite '
  225.   READ Enemys(I%).Typ 'used for facing direction
  226.   Draw_Enemy Enemys(I%).Sprite, Enemys(I%).Xloc, Enemys(I%).Yloc, From&, Layer(5) ' Where&
  227.  NEXT I%
  228.  
  229.  
  230. SUB Draw_Block (id%%, Xoff~%, Yoff~%, Ysize%%, From&, Where&)
  231.  _PUTIMAGE (Xoff~%, Yoff~%), From&, Where&, (0 + (16 * id%%), 0)-STEP(15, Ysize%% - 1)
  232.  
  233. SUB Draw_Pipe (Siz~%%, Xoff~%, Yoff~%, From&, Where&)
  234.  FOR I% = 0 TO Siz~%% - 1
  235.   Draw_Block 22, Xoff~% * 16, (Yoff~% - I%) * 16, 16, From&, Where&
  236.   Draw_Block 23, (Xoff~% + 1) * 16, (Yoff~% - I%) * 16, 16, From&, Where&
  237.   Blocks(Yoff~%, Xoff~% - I%).Sprite = 22: Blocks(Yoff~%, Xoff~% - I%).typ = Blocking
  238.   Blocks(Yoff~% + 1, Xoff~% - I%).Sprite = 23: Blocks(Yoff~% + 1, Xoff~% - I%).typ = Blocking
  239.  NEXT I%
  240.  Draw_Block 20, Xoff~% * 16, (Yoff~% - I%) * 16, 16, From&, Where&
  241.  Draw_Block 21, (Xoff~% + 1) * 16, (Yoff~% - I%) * 16, 16, From&, Where&
  242.  Blocks(Yoff~%, Xoff~% - I%).Sprite = 20: Blocks(Yoff~%, Xoff~% - I%).typ = Blocking
  243.  Blocks(Yoff~% + 1, Xoff~% - I%).Sprite = 21: Blocks(Yoff~% + 1, Xoff~% - I%).typ = Blocking
  244.  
  245. SUB Draw_Enemy (id%%, Xoff~%, Yoff~%, From&, Where&)
  246.  SELECT CASE id%%
  247.   CASE 1 'goomba
  248.    Sprite%% = 24: Siz%% = 16
  249.   CASE 2 'koopa
  250.    Sprite%% = 27: Siz%% = 24
  251.  Draw_Block Sprite%%, Xoff~%, Yoff~%, Siz%%, From&, Where&
  252.  
  253. FUNCTION Mushroom_Drag (valu!, frame%%)
  254.  Result! = valu! - Decel * frame%%
  255.  Mushroom_Drag = Result!
  256.  
  257. SUB INIT
  258.  DIM Size(64) AS LONG, FOffset&(64)
  259.  OPEN "Marios.gfx" FOR BINARY AS #1
  260.  GET #1, , c~%% 'number of records
  261.  FOR w% = 1 TO c~%%
  262.   GET #1, , FOffset&(w%)
  263.   GET #1, , Size(w%)
  264.   FOffset&(w%) = FOffset&(w%) + 1
  265.  
  266.  Level = _NEWIMAGE(7680, 480, 32) 'map full build '_LOADIMAGE("level1blur.bmp", 32)
  267.  Mario = LoadGFX(FOffset&(1), Size(1)) '_LOADIMAGE("mariofullnoblur.bmp", 32)
  268.  Layer(2) = LoadGFX(FOffset&(2), Size(2)) '_LOADIMAGE("levelbackground.bmp", 32)
  269.  Layer(3) = LoadGFX(FOffset&(3), Size(3)) '_LOADIMAGE("tilebase.bmp", 32)
  270.  Layer(4) = _NEWIMAGE(3840, 240, 32) 'map prebuild
  271.  Layer(5) = _NEWIMAGE(3840, 240, 32) 'sprite layer
  272.  
  273.  _CLEARCOLOR _RGB32(255, 255, 255), Mario
  274.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(3)
  275.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(5)
  276.  
  277. FUNCTION LoadGFX& (Foff&, Size&)
  278.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  279.  OPEN "temp.dat" FOR BINARY AS #3
  280.  dat$ = SPACE$(Size&)
  281.  GET #1, Foff&, dat$
  282.  PUT #3, , dat$
  283.  CLOSE #3
  284.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  285.  
  286.  

And you will need the GFX resource file too.
* Marios.GFX (Filesize: 14.03 KB, Downloads: 251)
« Last Edit: September 07, 2019, 04:09:37 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Peek at my Super Mario clone
« Reply #1 on: September 06, 2019, 03:10:38 pm »
Hi Cobalt, It looks very nice.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Peek at my Super Mario clone
« Reply #2 on: September 08, 2019, 11:23:25 am »
Cobalt, looking  fine so far.  When complete it would be a good one for the Samples Section?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Peek at my Super Mario clone
« Reply #3 on: September 08, 2019, 11:29:39 pm »
I get a "Bad record number" at line 308

All I did was copy/paste listing into IDE (saved in its own directory) and copied the gfx file into that directory.
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Peek at my Super Mario clone
« Reply #4 on: September 08, 2019, 11:39:02 pm »
False alarm. Linux is EXCEEDINGLY case sensitive when it comes to variables and 'filenames'. Modified the graphics filename in "Sub INIT" and the program ran as it should.

The game is looking good so far.... Will you be retaining the "super jump"? I could use that to avoid all the bad guys... lol
Logic is the beginning of wisdom.