Requesting Help with STI and Box2d

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
MagicFireball
Prole
Posts: 1
Joined: Mon Sep 19, 2016 12:30 am

Requesting Help with STI and Box2d

Post by MagicFireball »

Hello,

I've been working on a basic platformer as a practice project, and I've run into some problems and have a couple of questions.
1) With the code I have, whenever I move the character, it passes through all the tiles, even though they are collidable. How do I add a collision box to my character? How can I make it collide with the tiles marked as collidable?
2) For a platformer to actually be playable, the character needs to be able to fall. How can I add gravity to my game?

My .love file is attached.

Thanks in advance!

Edit: I changed the movement code a bit and am attaching the second .love file. Not sure if it will help, but better safe than sorry.
Edit 2: After playing around with the code a bit and switching to bump instead of box2d, I finally got it to work! The character does not move, but it's bounding box does, and it now collides with other collidable objects! Now I just need to figure out how to make the sprite move with the bounding box and how to add gravity. My new .love is attached.
Edit 3: I removed the movement code from my .love, but the player can still move in all 4 directions. How can I make it so that the player can not go down and only jump but not go continuously upwards? I am replacing my old .love (from edit 2).
Edit 4: I messed up in the previous edit and I was actually changing a different main.lua (also I never actually switched to bump, it's still with box2d). I have implemented gravity and now the player can move left and right, but not jump. Right now I just need some advice on how to implement jumping and then I should be good to go!
Attachments
Platformer.love
(145.88 KiB) Downloaded 152 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 74 guests