Page 1 of 2

Masai WIP - the birth of a platformer

Posted: Wed Jul 27, 2011 6:30 pm
by Cantide
Hi!!

This is my first post on the forum, although I've been trolling IRC for a week or two now, so I'll try not to 'iterate' anyone :)
I've started a simple platformer which will revolve around jumping, and will be mostly vertical.
I'm using love.physics a lot.
I've yet to figure out how to manage my code when it gets a little bigger, so levels / level design will follow when I get that figured out >.<

use 'a' and 'd' to move left and right, and 'space' to jump.
right click to throw a spear - (difficult to master...)
left click to jab - (a little faulty...)

the attacks seem to bug out if you're in the air and you aim down 30 degrees or so... maybe a handy exploit? u_u

A thousand thanks to everyone on IRC for helping me with my horrible mathematics :D Without your help, I wouldn't have gotten this far!

http://dl.dropbox.com/u/36318710/masai.love

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 7:02 pm
by nevon
It seems the player loses momentum as soon as they land. That may be realistic, but it doesn't feel very "platformery".

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 7:16 pm
by Cantide
nevon wrote:It seems the player loses momentum as soon as they land. That may be realistic, but it doesn't feel very "platformery".
I know, it actually 'bugs' me quite a bit! I'm not quite sure how to fix it though. It's got to do with the physics. The player bounces slightly, and can't move as quickly until the collision with the ground persists, i.e. he stops bouncing.
If anyone can fix this, please let me know :D

I'm also aware of the fact that you can 'climb' the grey platforms by tapping jump while the collision persists. This is a rather handy bug, which could be done away with with some better level design.

These aren't bugs, they're unintentional features! ^^;;;

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 7:26 pm
by slime
Cantide wrote:These aren't bugs, they're unintentional features! ^^;;;
You are a true programmer. :P

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 7:27 pm
by Ensayia
Hey, you finally made it to the forums!

Yeah, the physics are a bit wonky but I'm sure you can adjust that. Making collision and physics play nice without Box2D is HARD. I hope you have fun building your game!

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 7:27 pm
by Cantide
Thanks must go to bartbes for pointing out that I should use a restitution of 0 for both the player and the ground if I want to eliminate the bounce.
Still, I think it's a handy effect for different surface types like mud. I'll implement it later when I actually get that far :p

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 9:05 pm
by Tesselode
What's with the awkward control scheme?

Re: Masai game - the birth of a platformer

Posted: Wed Jul 27, 2011 11:15 pm
by tentus
Tesselode wrote:What's with the awkward control scheme?
WASD+Space, sans the WS.

I like what you've started Cantide. Some tips:

Code: Select all

    if (b == "player") then
       if (a == "static") then
can be:

Code: Select all

if b == "player" and a == "static" then
function love.keypressed() should generally be outside of love.load, though I suppose it works to have it in there.

Code: Select all

  if facing == "right" then
    love.graphics.draw(masai_torso, objects.ball.body:getX(), (objects.ball.body:getY() - 20), 0,  1, 1,  10, ypos_torso);
    love.graphics.draw(masai_head,  objects.ball.body:getX(), (objects.ball.body:getY() - 25), 0,  1, 1,  0, ypos_torso);
    love.graphics.draw(masai_foot,  objects.ball.body:getX(), (objects.ball.body:getY()), 0,  1, 1,  3 + xpos_foot1, -8 + ypos_foot1);
    love.graphics.draw(masai_foot,  objects.ball.body:getX(), (objects.ball.body:getY()), 0,  1, 1,  3 + xpos_foot2, -8 + ypos_foot2);
  elseif facing == "left" then
    love.graphics.draw(masai_torso, objects.ball.body:getX(), (objects.ball.body:getY() - 20), 0, -1, 1,  10, ypos_torso);
    love.graphics.draw(masai_head,  objects.ball.body:getX(), (objects.ball.body:getY() - 25), 0,  -1, 1,  0, ypos_torso);
    love.graphics.draw(masai_foot,  objects.ball.body:getX(), (objects.ball.body:getY()), 0,  -1, 1,  3 + xpos_foot1, -8 + ypos_foot1);
    love.graphics.draw(masai_foot,  objects.ball.body:getX(), (objects.ball.body:getY()), 0,  -1, 1,  3 + xpos_foot2, -8 + ypos_foot2);
  end
can be:

Code: Select all

	local ballX, ballY = objects.ball.body:getPosition()
	local facing_sign = 1
	if facing == "left" then
		facing_sign = -1
	end
	love.graphics.draw(masai_torso, ballX, (ballY - 20), 0, facing_sign, 1,  10, ypos_torso)
	love.graphics.draw(masai_head,  ballX, (ballY - 25), 0,  facing_sign, 1,  0, ypos_torso)
	love.graphics.draw(masai_foot,  ballX, (ballY), 0,  facing_sign, 1,  3 + xpos_foot1, -8 + ypos_foot1)
	love.graphics.draw(masai_foot,  ballX, (ballY), 0,  facing_sign, 1,  3 + xpos_foot2, -8 + ypos_foot2)
(You could also just make facing into a signed int (that is to say, 1 or -1), allowing you to skip the if statement for local facing_sign.)

If you change canRun (a boolean) to something like runSpeed (a number) you can remove some if statements and also allow for more options in the future.

Finally, in Lua, you don't need semicolons on the end of lines, or parenthesis in if statements, unless you feel like it makes things easier to read. Saves a bit of typing in the long run and clears up the screen if you leave them out.

Re: Masai game - the birth of a platformer

Posted: Thu Jul 28, 2011 12:47 am
by Tesselode
I think using W to jump would be better, since it's not like you need W and S to move forward and backward. However, that's only if you have to use the mouse to aim the weapon. If it just shoots in 1 or 2 directions, using the arrow keys for movement and one button for shooting would be much better.

Re: Masai game - the birth of a platformer

Posted: Fri Jul 29, 2011 8:24 am
by miko
Cantide wrote:Hi!!

This is my first post on the forum, although I've been trolling IRC for a week or two now, so I'll try not to 'iterate' anyone :)
Nice start! Please add "quit" option after pressing ESC and/or "q". BTW, this should be the first thing implemented in any game ;)