BASIC

Author Topic: Super Mario Bros engine  (Read 4279 times)

Offline Darmakwolf

  • Dr. Type
  • ****
  • Posts: 341
  • Aoooooooo - the werewolves of London!
    • View Profile
Super Mario Bros engine
« on: 2013-Mar-18 »
Thought I'd share my interesting Mario game engine with the GLBasic community, source code and all!

With it you will find the beginning of a really lame Mario knockoff called Ultra Marioid! (I intended for it to be an Android game, it works nicely on Kindle Fire HD 7")
What it does:

* full worldmap system with entirely customizable layouts in the same fashion as Super Mario Bros. 3. Levels are automatically linked by level number.
* infinite level size, not bound by a grid. Place objects freely on the screen!
* supports per-level music customization via ini file
* infintiely expandable object arsenal. make a bitmap named obj_(number).bmp and it's usable in-game if it's in the media folder.

Test the demo level by pressing new game. On the world map, you can either click a position to move to or use the arrow keys. Stepping on a level indicator will initiate the level.

Controls:

Arrow keys to move
X to jump

Being optimized for touch screen mechanics, some blocks are "tappable" to break them, so you can simply use the mouse on a PC. When compiling for android, remember that your screen MUST support 1280x800, such as the Kindle Fire HD, unless you rewrite some of the code to alter it. Compiling for Android automatically switches on the NES-style on-screen controls.

Editing a level: Press "EDIT" at the start screen. Use arrow keys <--- and ---> to select a level, enter to pick what one. A yellow "?" will appear if the level has not been made yet - so just press enter to make it!

The arrow keys fly you around the map. Shift + arrow key = fast move. SPACE bar saves the level.

In the editor: press "O" to open the objects list. You can select an object from here, or simply press the + key or the - key on the numpad to "scroll" through objects available. Click to place an object. Snap objects to the left, right, top, or bottom of other objects by selecting them with the mouse and using W,A,S, or D on the keyboard.

Scroll with the scrollwheel on the mouse to change the properties of the next object to place. Mousing over any object and using the / or * keys on the numpad changes the SELECTED object's properties. By default, objects act as solid blocks. They can become moving platforms, breakable by jumping under them, or act as coins. In game, you can break ANY block on PC by holding shift and clicking it. In the editor, delete a block by mousing over it and pressing delete. The shift-click thing is more of a beta-testing feature, it's obviously not for the final product.

Keep in mind Mario will start in the middle of the screen on a newly loaded map, so build accordingly. Pressing T opens a slider to select how many "taps" the next object placed requires in order to explode it in-game. Set this back to zero to disable it.

Remember: this is not a finished product. With some additions it can be made into a fully finishable game, but as it is, it's just a sort of fun little experiment.

Download full project: http://www2.zshare.ma/yrudnqo1weiq

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4133
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Super Mario Bros engine
« Reply #1 on: 2013-Mar-18 »
That really looks like an excellent engine you've got there. Cheers Darmakwolf. I hope others can make good use of it.
Nice one :)
I came. I saw. I played.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4977
  • O Rly?
    • View Profile
Re: Super Mario Bros engine
« Reply #2 on: 2013-Mar-18 »
Maybe it's a wrong name for this engine :)

I'll give it a try at home.
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Super Mario Bros engine
« Reply #3 on: 2013-Mar-18 »
Thanks Darkmawolf, I am definitely going to give that code a good browse as never really looked into platformers from a programming standpoint, played loads of them though  :D

Lee

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline Marmor

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 908
  • 96A285CC
    • View Profile
    • my youtube channel
Re: Super Mario Bros engine
« Reply #4 on: 2013-Mar-18 »
da code ! da code ! he give us da code  :good:

yeah thx a lot ! i learning some from everyone !

Offline Darmakwolf

  • Dr. Type
  • ****
  • Posts: 341
  • Aoooooooo - the werewolves of London!
    • View Profile
Re: Super Mario Bros engine
« Reply #5 on: 2013-Mar-20 »
I forgot to mention that in game you can press and hold F1 to display object collision boxes. They flash red when they're hit. F2 is debug-mode flying, hold it to float upward.

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: Super Mario Bros engine
« Reply #6 on: 2013-Mar-20 »
Love the engine, especially as I'm in the process of writing my own. I do soooooooo wish the code was indented though. Any GLB Beautifier around???
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Super Mario Bros engine
« Reply #7 on: 2013-Mar-20 »
Love the engine, especially as I'm in the process of writing my own. I do soooooooo wish the code was indented though. Any GLB Beautifier around???

There is this one http://www.glbasic.com/forum/index.php?topic=3243.msg23711#msg23711

Think I tried it many moons ago when I started with GLB but do it as I go along now  :D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: Super Mario Bros engine
« Reply #8 on: 2013-Mar-20 »
Love the engine, especially as I'm in the process of writing my own. I do soooooooo wish the code was indented though. Any GLB Beautifier around???

There is this one http://www.glbasic.com/forum/index.php?topic=3243.msg23711#msg23711

Think I tried it many moons ago when I started with GLB but do it as I go along now  :D

Lee

Unfortunately not there anymore :-( Anyone have a copy floating around?
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Super Mario Bros engine
« Reply #9 on: 2013-Mar-21 »
Found it on a backup  =D

Lee

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1752
    • View Profile
    • Homepage
Re: Super Mario Bros engine
« Reply #10 on: 2013-Mar-21 »
I really should get my homepage up again... Glad you had use for it :-)

Offline Darmakwolf

  • Dr. Type
  • ****
  • Posts: 341
  • Aoooooooo - the werewolves of London!
    • View Profile
Re: Super Mario Bros engine
« Reply #11 on: 2013-Mar-21 »
Sorry I have a strange way of writing code... indenting somehow makes my OCD angry, but not blocks of scary looking algorithms :P

I think you will find it is very efficient code though. It skips rendering off screen objects and uses a sprite array for sharing graphics between objects so that minimal memory is used.
« Last Edit: 2013-Mar-21 by Darmakwolf »

Offline CW

  • Mr. Polyvector
  • ***
  • Posts: 155
    • View Profile
Re: Super Mario Bros engine
« Reply #12 on: 2013-Mar-26 »
This is same really nice work, Darmakwolf. I like your deft sprite manipulations, and you absolutely nailed the feel and physics of Mario's jump. Even without baddies on the field, the challenge of working my way back up to the top through careful jumping (up, out and back) kept me engaged. You have a very nice package there. Well done. I look forward to playing with the editor tomorrow. I know it's a demo, but if you decide to put more work into it, I hope you keep us in mind for another peek.
-CW