Jump to content


Photo
- - - - -

3D movements in 2D game


  • Please log in to reply
16 replies to this topic

#1 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 382 posts
  • Version:GM:Studio

Posted 28 July 2011 - 10:59 PM

  • Title: 3D movements in 2D game
  • Description: Shows my method on how to do 3D movements in 2D game
  • GM Version: :GM8:
  • Registered: No
  • File Type: .gmk
  • File Size: 14 Kb
  • File Link: Download at YoYo Games.com
  • Required Extensions: None
  • Required DLLs: None
Summary

UPDATED to ver2!!
- collision fixed!
- it's 100% lite friendly now!

This example shows my method on how to make three-dimensional movement in 2D games, just like in classic beat em ups or brawler games (i.e. Golden Axe, Final Fight, Captain Commando, etc). What three-dimensional movements means is that object not only move around in two planes; x and y (like platformer games, top down shooters, etc) but it move around in 3 plane; x,y,and z. So, in this basic example, I made the player not only can move in 4 directions, but also can jumps, and fall from higher areas. The example is heavily commented, but your question and suggestion is very well come! And don't forget to see the game information/help.
Posted Image

Edited by Fihrilkamal, 25 April 2012 - 11:01 AM.

  • 1

#2 _219941

_219941

    GMC Member

  • New Member
  • 9 posts

Posted 24 August 2011 - 01:08 AM

i have a question man, how can i animate other actions within this movement, using the draw command, kind of like walking forward, jumping, attacking, i have a game using this code but every other animation i had programed is dissabled.
  • 0

#3 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 382 posts
  • Version:GM:Studio

Posted 25 August 2011 - 06:40 PM

i have a question man, how can i animate other actions within this movement, using the draw command, kind of like walking forward, jumping, attacking, i have a game using this code but every other animation i had programed is dissabled.

If you want to use your own sprites and animation within obj_player, then here is the code, see obj_player 's draw event, and click on the second piece of code, you should see this:
draw_sprite(spr_player,0,x,y+z)//draw the player
Change that code in to:
draw_sprite(sprite_index,image_index,x,y+z)//draw the player
That will enable the object to have different sprites and animations. :)
  • 0

#4 HeadInjuryGames

HeadInjuryGames

    AKA Suppercut

  • GMC Member
  • 198 posts
  • Version:GM8.1

Posted 27 August 2011 - 07:58 PM

Moving against walls is a bit glitchy. I need my character to just face left/right (I'm making a beat em up RPG type thing with a Rogue Galaxy/Kingdom Hearts combat system) and whenever I hold a key against a wall (say up), I can't move along the wall (left or right), and my character slides along it really idiotic-looking.
  • 0

#5 Phescosteguy

Phescosteguy

    GMC Member

  • New Member
  • 1 posts

Posted 30 August 2011 - 12:29 PM

Hello! First, congratulations on the great example!

Im experiencing the same problem the user above. And also something else: the jumper function doesnt seem to work with me. I exchanged the player sprite and it doesnt work anymore.
  • 0

#6 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 382 posts
  • Version:GM:Studio

Posted 30 August 2011 - 02:26 PM

Moving against walls is a bit glitchy. I need my character to just face left/right (I'm making a beat em up RPG type thing with a Rogue Galaxy/Kingdom Hearts combat system) and whenever I hold a key against a wall (say up), I can't move along the wall (left or right), and my character slides along it really idiotic-looking.


It work, but yes, I admit it's still imperfect, but I'll try to modify that. If you want, you can change the code inside obj_player and then collision with obj_wall that's where I put the "Moving against walls" code.

Hello! First, congratulations on the great example!

Im experiencing the same problem the user above. And also something else: the jumper function doesnt seem to work with me. I exchanged the player sprite and it doesnt work anymore.


Objects in this example relies on collision masks and bounding boxes, so don't forget to manually set those in the sprite menu. I hope it helps :)
  • 0

#7 greenall69

greenall69

    GMC Member

  • GMC Member
  • 186 posts

Posted 01 September 2011 - 12:00 PM

Looking good! I think you should keep working on this example it could be really good. Much better than i expected it to be.

However the moving along the walls need polishing up abit.
  • 1

#8 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 185 posts

Posted 01 September 2011 - 04:45 PM

This is a great example. Pressing against a wall is a little slippery/jittery for my taste, but that can easily be tweaked.

EDIT

After playing with it a bit, there are a few things that worry me about actually using a system like this, and maybe you can make some suggestions on how this can be modify for a "real" game.

First off, if your character's are not squares, it can immediately break the illusion. Or, at the very least, if I want my character's collision mask to be around his feet, but his shoulders are massive (Think Hagar), as soon as I push up against the wall, I will clip through and show the tile structure.

Additionally, it was common in Golden Axe and some of the old D&D brawlers to have diagonal "cliffs" that you could jump up or jump down.

I guess what I'm saying is that the example is nice, but I would really like to see an actual, non-cube character and some diagonal walls.

If you want to try and tackle this and need some sprite sheets for a beat 'em up (walk, run, jump, etc) PM me and I can provide some.

Edited by Pixelated_Pope, 01 September 2011 - 07:18 PM.

  • 1

#9 LegoGuy24

LegoGuy24

    GMC Member

  • GMC Member
  • 9 posts

Posted 24 April 2012 - 03:49 PM

So If I want to make a beat 'em up,I must get the code from your tutorial,or what?
  • 0

#10 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 382 posts
  • Version:GM:Studio

Posted 24 April 2012 - 05:26 PM

So If I want to make a beat 'em up,I must get the code from your tutorial,or what?

No, it's just an example, there's so many ways to make beat 'em ups. And not every beat 'em up use 3-plane movement like this. It's all up to you.
  • 0

#11 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 24 April 2012 - 10:47 PM

___________________________________________
ERROR in
action number 1
of Draw Event
for object obj_hud:

Error in code at line 2:
d3d_set_projection_ortho(0,0,640,480,0)
^
at position 2: This function is not available in the Lite Edition.

Iol!
looks like this tut is for registered, but that is the only code that requires it I just made it into a comment. :P
But the movements seem like they are perfect for glass blocks!
still seems to be imperfect. :)
EDIT:
I see that the depth is constantly changed every time you press up and down, I think this causes the block to slide.
also the shadow is a little crazy, because:
if you're at an edge the shadow should show at the floor!
it would be helpful if that was created

Edited by creators124, 25 April 2012 - 12:23 AM.

  • 0

#12 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 382 posts
  • Version:GM:Studio

Posted 25 April 2012 - 10:59 AM

It's UPDATED !! Now there's no idiotic sloppy glitchy collision anymore, and it's 100% lite compatible! Thanks all for your comments.

It's still need improvements though :)

Edited by Fihrilkamal, 25 April 2012 - 11:05 AM.

  • 0

#13 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 25 April 2012 - 03:05 PM

now any way to make shadow appear on floor when your at the edge?
it would be even more better!
if you don't know how to do it for lite, could you tell me a code(s) to do it for pro?
  • 0

#14 Krenzathal77

Krenzathal77

    GMC Member

  • GMC Member
  • 121 posts
  • Version:GM:Studio

Posted 10 April 2014 - 03:20 PM

Excellent tutorial! The jumping in my Golden Axe 2 remake was one of my big worries as I've only been using game maker and GML for week or two and I'll admit It took a while to figure out how to use your code in my game (And I'm still not sure how it actually works haha!) but anyway, thank you it's just want I needed. A full credit is all yours as I would have probably given up if not for the example.

Just a couple of questions, when I jump I want to change the sprite to a jumping pose on the way up and a different jumping pose on the way down (and same if I push left/right and jump) I tried changing the sprite index to match certain zspeed numbers but it didn't work.

And could I make the z variable global to use with enemies? Not just jumps but things like being knocked up in the air with a hit?

P.S. Sorry for asking questions as you've done so much for me and my game already.


Edited by Krenzathal77, 10 April 2014 - 03:20 PM.

  • 1

#15 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 382 posts
  • Version:GM:Studio

Posted 10 April 2014 - 07:26 PM

Excellent tutorial! The jumping in my Golden Axe 2 remake was one of my big worries as I've only been using game maker and GML for week or two and I'll admit It took a while to figure out how to use your code in my game (And I'm still not sure how it actually works haha!) but anyway, thank you it's just want I needed. A full credit is all yours as I would have probably given up if not for the example.

Just a couple of questions, when I jump I want to change the sprite to a jumping pose on the way up and a different jumping pose on the way down (and same if I push left/right and jump) I tried changing the sprite index to match certain zspeed numbers but it didn't work.

And could I make the z variable global to use with enemies? Not just jumps but things like being knocked up in the air with a hit?

P.S. Sorry for asking questions as you've done so much for me and my game already.

Thanks a lot Krenzathal77 for your appreciation.

But, I have to apologize for I might not be able to help. But here's what I can say;

This example is still far from perfect, nor it is designed to show example on animations, attacking, etc. So, I suggest you make your own animation system, and I would advise you to use many "state"objects  (for example, obj_player_jumping, obj_player_ground, obj_player_attack, etc then they are parented to obj_player), that was the easiest system to make beat em ups games I think.

 

You don't need to make Z a global variable, just make sure it is created in each enemy objects. And making enemies that's knocked in the air is easily achieved with my aforementioned "state" objects system. So, I really suggest you to take a look at GM's parenting system.


  • 0

#16 Krenzathal77

Krenzathal77

    GMC Member

  • GMC Member
  • 121 posts
  • Version:GM:Studio

Posted 10 April 2014 - 08:40 PM

Great, thanks for the advice! :)


  • 0

#17 VChuckShunA

VChuckShunA

    GMC Member

  • New Member
  • 12 posts
  • Version:GM:Studio

Posted 20 April 2014 - 08:04 PM

I'm having trouble with jumping. How do I make him change sprites only while In mid air ???
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users