Creating a 2.5d game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Creating a 2.5d game
So I am going to making a beat em up so do I need to make a small restricted area where the characters can move up and down and left to right
Very new programmer dont judge
Re: Creating a 2.5d game
No.
But seriously, there is no reasonable question here. How should we know what you should or should not do.
But seriously, there is no reasonable question here. How should we know what you should or should not do.
- Calandriel
- Prole
- Posts: 39
- Joined: Wed Apr 22, 2015 9:00 am
Re: Creating a 2.5d game
You can use meshes to draw your textures, and draw every vertex with algebra that will help you simulate the distortion. Im planning to use something like this:
http://www.flipcode.com/archives/Plotti ... reen.shtml
but I believe that you dont really need this in your game. all you need is check if the entities(player, enemies) are at a same height. if higher, then you're behind them, if lower, you're in front. It's really simple. Btw, could you be more specific about the features you want in your game
http://www.flipcode.com/archives/Plotti ... reen.shtml
but I believe that you dont really need this in your game. all you need is check if the entities(player, enemies) are at a same height. if higher, then you're behind them, if lower, you're in front. It's really simple. Btw, could you be more specific about the features you want in your game
If violence is not solving all your problems, You're simply not using enough of it.
Twitter: https://twitter.com/Calandriell Some news about wtf I'm doing.
Tumblr:https://www.tumblr.com/blog/calandriell I use to draw some random stuff.
Twitter: https://twitter.com/Calandriell Some news about wtf I'm doing.
Tumblr:https://www.tumblr.com/blog/calandriell I use to draw some random stuff.
- bluedudex2
- Prole
- Posts: 11
- Joined: Thu Aug 27, 2015 8:56 am
Re: Creating a 2.5d game
You can check this quick file I made. The base code to make the player stay where you want him is
In the demo, it is basically saying if character's Y + it's height goes over (or bellow) the upper Y and lower Y of the blue box then keep him within that box. Hopefully it makes sense and I added an X bound as well but that is not required for what you want. So with collision instead of thinking about it as a 3d plane think about it as boxes on a 2d plane and drawing graphics to give the illusion of depth.
And BTW I hard coded quite a bit with this code and it may be a bit sloppy but I just wanted to get the basic idea across.
Code: Select all
if player_x < 100 then
player_x = 100
elseif player_x + player_w > 700 then
player_x = 700 - player_w
end
if player_y + player_h < 400 then
player_y = 400 - player_h
elseif player_y + player_h > 500 then
player_y = 500 - player_h
end
And BTW I hard coded quite a bit with this code and it may be a bit sloppy but I just wanted to get the basic idea across.
- Attachments
-
- main.love
- (531 Bytes) Downloaded 195 times
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Creating a 2.5d game
This should accomplish the same thing: (Untested)bluedudex2 wrote:Code: Select all
if player_x < 100 then player_x = 100 elseif player_x + player_w > 700 then player_x = 700 - player_w end if player_y + player_h < 400 then player_y = 400 - player_h elseif player_y + player_h > 500 then player_y = 500 - player_h end
Code: Select all
player_x = math.max(math.min(player_x, 700 - player_w), 100)
player_y = math.max(math.min(player_y, 500 - player_h), 400)
- bluedudex2
- Prole
- Posts: 11
- Joined: Thu Aug 27, 2015 8:56 am
Re: Creating a 2.5d game
Like I said, I just made sloppy prof of concept.Jasoco wrote: This should accomplish the same thing: (Untested)Code: Select all
player_x = math.max(math.min(player_x, 700 - player_w), 100) player_y = math.max(math.min(player_y, 500 - player_h), 400)
Anyway, I always forget about the basic math functions like math.min/max, that is way simpler!
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Creating a 2.5d game
Test it first and make sure it works the same way but I'm pretty confident that should be exactly the same outcome. Don't ask if there's any performance loss. Most likely not.
You could also simplify it more if you create a clamp function and use that instead.
You could also simplify it more if you create a clamp function and use that instead.
- bluedudex2
- Prole
- Posts: 11
- Joined: Thu Aug 27, 2015 8:56 am
Re: Creating a 2.5d game
Couldn't get around to testing it until now and when I do try it, it keeps throwing up an error saying: Bad argument #1 to 'min' (number expected, got nil)
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Creating a 2.5d game
The first argument in math.min is the player position. The fault lies with your code. Are you making sure player_x and player_y are actually number values first?
- bluedudex2
- Prole
- Posts: 11
- Joined: Thu Aug 27, 2015 8:56 am
Re: Creating a 2.5d game
Stupid mistake on my part. The code works but I edited so that the bottom of the player stops when it hits the top of the blue square (well at least giving the illusion of the bottom of the player stopping at the top of the blue square)Jasoco wrote:The first argument in math.min is the player position. The fault lies with your code. Are you making sure player_x and player_y are actually number values first?
Code: Select all
player_x = math.max(math.min(player_x, 700 - player_w), 100)
player_y = math.max(math.min(player_y, 500 - player_h), 400 - player_h)
Who is online
Users browsing this forum: Bing [Bot] and 9 guests