February 24, 2020, 06:21:52 AM

Author Topic: a mario like game  (Read 1079 times)

Offline Hardcoal

  • Sr. Member
  • ****
  • Posts: 373
a mario like game
« on: February 22, 2018, 04:27:54 AM »
Hi.. a rookie question..
when you want to make a scroll game like mario bros ..
how exactly do you do the collision?

A) do you use physics engine?
B) Non physical engine?
C) You create your own collision system

I will be glad to see a simple code for a collision game in blitmax if possible..

Thanks and God bless..
Happy New Year

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2297
Re: a mario like game
« Reply #1 on: February 22, 2018, 05:18:28 AM »
2D Mario games would not of used any physics engines as they would of been a complete system hog. A lot of modern newbie coders automatically dive on 2D physics for 2D platform games ( for obvious reasons ) but 99% fail as they just assume that the physics engine will handle all the jumping / gravity and collisions without any work on their side. 2D physics only works well on a 2D platformer when you know how to code a 2D platformer. There are no super simple shortcuts to skip the core hard work.

I can't state exactly how Mario worked but I'm pretty sure it was pretty much all tile based calculations with offsets and perhaps even distance between x1 / y1, x2 / y2.
Until the next time...

Offline Hardcoal

  • Sr. Member
  • ****
  • Posts: 373
Re: a mario like game
« Reply #2 on: February 22, 2018, 05:24:54 AM »
i know that physics is not the right approach ,, although i try to adapt some way using it..
but blitz3d collisions should do the trick..
I dont mind programing my own collision system..
i am just interested to hear about different approaches of collisions methods on this type of games..
Happy New Year

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2297
Re: a mario like game
« Reply #3 on: February 22, 2018, 05:36:09 AM »
I really wouldn't go down the physics route for a 2D platform game. I think you'd end up coding way too many work arounds to accommodate the reactions. I do think you'd be better off controlling the world as you want it to be.

As already mentioned regarding collisions there aren't really many methods. Disregarding a whole physics engine then you're just left with tlle based with offset, distance based and of course pixel collision. Very few do pixel perfect collision these days
Until the next time...

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1483
Re: a mario like game
« Reply #4 on: February 22, 2018, 06:26:38 AM »
original mario games are based on single 2d screen of data.
scrolling was done by shifting the screen and drawing the next column of tiles
redraw was hidden by wider borders at the sides

There were a lot of custom hardware tricks used, to make a static screen look like it was scrolling.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2718
Re: a mario like game
« Reply #5 on: February 22, 2018, 08:35:21 AM »
There are literally 100s of side scrolling tutorials on the web.

Basically you check if you collide with a tile - if you collide with a tile you could do the better collision detection (eg. for slopes).
"Mario" would have basic gravity applied everytime, jumping brings in "upwards force". Then it is pure math ...


http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/
or
https://gamedevelopment.tutsplus.com/tutorials/basic-2d-platformer-physics-part-7-slopes-groundwork--cms-28472


bye
Ron

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1038
Re: a mario like game
« Reply #6 on: February 23, 2018, 08:21:32 AM »
i would do a 2 passes collisions detection :
the screen would be divided in tiles (square areas)

Code: [Select]
;before moving the entity, store its old position
;depending on its movement vector, calculate the new position
;check if turningmoving entity will be in an area having "obstacles tiles" (or you could use radiuses and a distance check)
 ;if yes
 ;check if the outline (pixels) of the turningmoving entity intersects with the outline (pixels) of the obstacle
 ;if yes
  ;move it back at its original position and do a unit by unit (pixel by pixel) movement before the 2 outlines (pixels) intersect to find the appropriate repositionning position and collision point
 ;if no
  ;position the turningmoving at the new position
;if no
 ;position the turningmoving at the new position

for a turningmoving entity which is moving fast, you will have to check for a possible collision with an obstacle in all the tiles around the vector from oldposition to newposition, to prevent the turningmoving entity to go through obstacles...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1483
Re: a mario like game
« Reply #7 on: February 23, 2018, 08:30:12 AM »
Similar to what RemiD said.
I wrote a mario-like game a few decades back. It used a tile based grid.

You just need to check the current tile you are on/near. The same for any enemies.

Think of a tile as:
no contents - can move
blocked contents - movement is blocked - check that dropping/falling wont put you inside this tile!
various diagonals - same as blocked, but you can occupy part of the tile - this can be extended to automatic sliding in a certain direction

This first test would be blocked and non-blocked tiles (don't even start without getting this working 100% first)

Offline Hardcoal

  • Sr. Member
  • ****
  • Posts: 373
Re: a mario like game
« Reply #8 on: February 23, 2018, 02:52:00 PM »
I still want to experiment with physics as well..
but thanks for all the tips..
I've being and still is, busy more on the editor.. than on making games :)

I can do 100 times the same thing until i get it right.. if i have a good mood.
I dont give up so easy if at all.

For Example, I've built like 10 times map editors and everytime i learn something new..
I willing to sacrifice experiments.. as long as I get what I want..

Thats one reason I came to the conclusion that IDE's arnt so Efficient as I want them to be..

I've seen some IDE's that Do some of the things I desire..
Like a collapsed remarks Section on B4A IDE.. for Android..
So some people do think like I do..
But I know you can do much more..

I'm trying various methods because eventually I Do want to make Games

Im trying direct approach without and Editor Framework..
And also simultaneously trying other methods.. and Concepts..
Its like a research as well..

I just really hope something will come out of it eventually..




Happy New Year

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal