Archived

This topic is now archived and is closed to further replies.

bubach

Mario clone.. (DOS 2D)

Recommended Posts

I am working on a 2D (in DOS =)) super mario clone and have some trubble. The biggest problem is the collison detection. How to know were the ground is, and what to collison test? The question is, should i make it tile/sector(some sort of world map?) based to make it all much simpler? And how am i going to do it? Scrolling. How to and examples please... =) If you have some example game (that uses some usefull technic or is similar to super mario) with source-code please post it.. Thanks..

Share this post


Link to post
Share on other sites
Go to www.makegames.com , there´s a free book about how to make a 2D sidescroller game in DOS. Hope that helps!

Share this post


Link to post
Share on other sites
collision detection is an issue in a game my friend and i are making as well, but it must be more accurate because it is a fighting game. go to ignacio''s site. it should be helpful!! !)

Share this post


Link to post
Share on other sites
I´m making a sidescroller too and this article was really useful when I planned the collision detection module: http://www.fastgraph.com/fsm.html

Share this post


Link to post
Share on other sites
I have the source of a semi-mario clone....it isn''t complete though...there''s no enemies, no bigness, no flowers. But it''s a start if someone would be willing to host i can just email you the link...I can''t post it here cuz my bandwidth will be totally eaten up

Share this post


Link to post
Share on other sites
ok, thanks. i have already had a look at makegames.com/sidescroller but it is based to much on fastgraph.. when i discovered that i stopped reading, maybe i should read it anyway.. =)

feel free to email me links to anything that could help me..
( sourcecode!! =) )
bubach85@hotmail.com

i have a "almost working" test_coll() rutine, but another problem is the number of tests that i will have to do..

i think that the best thing to do is to make the world tile and sector based, but how do i do that?

and the scrolling?

thanks alot anyway..

Share this post


Link to post
Share on other sites
and another thing (or two)..
my jumpingcode sucks, anyone that got a good one? and when the player moves it should check so that it is ground under it.. how do i do that?

thanks..

Share this post


Link to post
Share on other sites
Look a pixel under the player. If you hit a solid tile then he''s on ground, and you can allow the jump button to make him jump. Note that if he''s not on ground any more then he should start falling.

Almost fiendish in its simplicity.

For collision, try to make a routine that takes two vectors as inputs (the starting position and the desired position) as well as something that represents the shape you''re trying to collide (like the radius of a sphere). The function could then modify the desired position on exit to say "this is where you hit a wall", and return true to say it did so.

Break the problem up into smaller ones first.


Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

Share this post


Link to post
Share on other sites
but to use any of those technics i need to make it tile/sector based.. how do i do that? some sample code?

thanks

Share this post


Link to post
Share on other sites
as it is now i have a big picture as background, the player character and a box on the ground..
i have a variable GROUND that contains the x value of the ground.
(this sucks!)
i can make the background to several 16x16 tiles, but how can i do a rutine that draws the world by a argument
( like draw_world(level1); ) and level1 is some sort of array or something? and when the world is drawed... i have so _many_ questions.... the best thing would be if i could find some sample sourcecode..

someone out there that knows both pascal and c/c++?
have a look at this:
http://home.wxs.nl/~mike.wiering/mario/

it is a _very_ good mario clone, but sadly i do not understand that much of the code.. because it is in pascal, and of course it is harder to understand code that i have not written myself.. =)

Share this post


Link to post
Share on other sites
because i think that it is hard to make the things you tell me into code if i do not have any clue how to do it..

and i do not want to make a pong, and if you do not _want_ to do something it will never be done..

do anyone know some good site with information that i would need to make my mario clone?

Share this post


Link to post
Share on other sites
Let's see.... if you want to do collision detection and scrolling, make a 2d array of ints, like this:

int map[mapheight][mapwidth];

You could also make an array of chars, the advantage being ease of initialization. You could very easily set up your map with a char array like this:

char map[mapheight][mapwidth]={"04231000032.....",
"................"};

Where the numbers are indices to your graphic images for tiles. As far as collision detection goes, you could have another array containing either a 1 or a 0, 1 being solid. You could also make a tile struct containing this info. After this, in order to test for collision, do something such as this:

while (collision_array[player_y/16][player_x/16]==1)
{

//player is colliding with something...

}

Scrolling is actually very easy. First you should have two global ints, named scrollx and scrolly, or something, then all you have to do is this:

for (int y=0; y{
for (int x=0; x{
DrawObject(objTile,x*32-scrollx,y*32-scrolly,map[y][x]);
}

}

Assuming map[][] is an int array, in this previous example it represents the current tile frame to display. If it were a char array, simply append " -'0' " (without the double quotes) to the array in the drawing function.

Now to calculate the position of your other objects, simply subtract scrollx and scrolly from their coordinates, then modifying the latter two will scroll the screen.

Hope that made sense, it's still a little early. Good luck with your game!




"Skepticism.... that great rot of the intellect." - V.H.
Bah, what does HE know?


Albekerky Software


[edited by - sliderag on May 28, 2003 8:47:59 AM]

Edit: The for loops are messed up. Just make the range for x and y the width and height of the map, and then increment them.

[edited by - sliderag on May 28, 2003 8:50:09 AM]

Share this post


Link to post
Share on other sites
Thanks for your reply! it was the only helpful so far.. But it would be nice to get more opinions on this.. Some sample code would be nice..

thanks..

[edited by - bubach on May 28, 2003 2:35:17 PM]

Share this post


Link to post
Share on other sites
another thing, how can i know witch direction the player collided with for example a monster..
if the player jumps on a monster (collision from top) it should die, but if the player walks into the monster the player dies.. (collision from left right or down)..

how do i unload the tiles and sprites that are not neccesary from memory?

thanks.. (sorry for my spelling, i am sleepy )

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I admire your go get em attitude, but you need to realize that you may be taking on too much. There is a reason why people are saying make Pong and Tetris. These games are simple, yes, but they each have different elements in them that your Mario clone have. Pong will teach you simple collision and movement. Tetris will teach you tile based collision (hint hint) and movement. After that you might try your hand at PacMan which builds on Pong and Tetris but also adds enemies with "AI". Plus, you will have the satisfaction of a completed game rather than a weak demo. You will learn so much from these smaller games that you will laugh when you look back. Start smaller or you are going to hit brick walls at every turn.

Share this post


Link to post
Share on other sites
If you don''t know where to start on a game project, how will you ever know how to do the later things.. if you really want to play a mario game think about how they would have made it.. think about how its displayed on the screen, play it and watch what happens when you do certain things...

finally, start putting your research together... I beleive that if you work at it that you can definitly make whatever game you want as your first game, it will just take longer then someone who is making their 5th or 6th..

I personally try to avoid looking at the code of other peoples projects... Tutorials and Snipets are different because they just point you in a direction.. the problem with looking at other people projects and learning from that is what did you really learn when you make yours? I think it would be to tempting to just copy parts and not really learn what its doing...

Share this post


Link to post
Share on other sites
ok, i get it.. but i rather make a mario clone as my first real game even if it takes more time!

and i know that sometimes it can be tempting to copy & paste code without knowing what it does...

i tutorial on how to make a sidescroller like mario would be great! someone got one (or knows of a good book)??

thanks anyway...

PS
i wrote that GROUND stores the x value of the ground! of course i mean the y value...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
"how can i know witch direction the player collided with for example a monster.."

first check if they collided.
(assuming players x,y pos is top,left corner) check yPos + height of player and see if it is equal to the monsters yPos.
if it is then the player must be on top of the monster otherwise its hitting from the side

Share this post


Link to post
Share on other sites
Ignacio!!
Are you from Argentina I just Cant believe it!! Im from San Juan..Im always on this forums!!
Are you a game programmer?...thats so good...there are not many game programmers around here..am I wrong?
Please contact me dude..Later

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I know somewhat how you are feeling. A few years ago, I learned how to code in C++. I got better over a year and read a lot of books. I wrote a really bad Mario kind of game (way simple, hardly anything in it) in DOS, but wanted to step up to Windows. With Windows quickly came DirectX. If you want to code good quality games, I suggest learning DirectX and the basics of the Windows API. The best book on game programming I''ve got is titled "Tricks of the Windows Game Programming Gurus" and the author is Andre LaMothe. This guy is basically an expert. It starts out by explaining the basics of Windows programming. Don''t skip over it -- you need to understand a lot of it. Then it gets into DirectX, specifically DirectDraw, which is basically all of the 2D programming stuff in DirectX (what you need). It discusses simple graphics (lines & shapes...), bitmapped graphics (pictures), and how to put all that on the screen. It goes through DirectInput (keyboard, joystick, & mouse) and DirectSound (wav) & DirectMusic (midi). It discusses game logic, the main game loop, double buffering, and lots of good stuff like collision detection and physics. It costs about $50 and it''s worth it if you want to code this stuff. It doesn''t really cover much 3D, so don''t let it deceive you about that. Besides, there are enough better books covering 3D that this should just give you a good foundation for 2D programming. Get the book, read it through, learn the code, and you''ll be able to start making what you want to. It comes with the Intro version of Visual C++ 6 as well as the DirectX SDK. I''m working on a similar project myself and I am using it as a reference even as I write this. Good luck with your game. Also, if you''re writing a Mario game, keep playing through the originals and play them from a programming perspective. Get ideas, watch how things are done, and take notes. But buy the book. -- Gilligan

Here''s the book (2nd edition) on Amazon.com
http://www.amazon.com/exec/obidos/tg/detail/-/0672323699/qid=1054493727/sr=1-1/ref=sr_1_1/103-3611839-2696668?v=glance&s=books

Share this post


Link to post
Share on other sites
ok, thanks..
i would really want to be ably to do it in dos first, but i may move it to windows later..
i think i will buy that book, becasue the collision detection is the same on all platforms..

to all of you that has made a mario clone, can you please mail me some (or all) source code?

thanks..

Share this post


Link to post
Share on other sites
Instead of DOS, I would recommend something like SDL, which is a cross platform library for writing games with. It''s high level enough so you don''t have to worry about DirectX, and low level enough so you still have lots of control over how your game works and looks.

Plus there''s loads of documentation and tutorials out there.


Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

Share this post


Link to post
Share on other sites