Page 21 of 92

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Thu Aug 21, 2014 6:24 pm
by Cryogenical
If I wanted to make the map change based on the player colliding with a specific tile (like a doorway), how would I go about re-positioning the character and drawing the new map?

Should I make a separate lua file for map changing, and functions for each map to position the character? Or should this be done in the main.lua?

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Thu Aug 21, 2014 6:28 pm
by Rukiri
There should be a property value you can key in and if player touches == to the properties location you'd switch the map.
Repositioning the player can be tricky, are you going on a grid system? if so you'll need to write a moveto function which then you can place player.x and player.y at the specific location you need it to be.

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Thu Aug 21, 2014 7:21 pm
by Cryogenical
Is there a way using the base love framework to put a debugger of sorts say in the top left hand corner saying the player's x and y position, and updates as the player moves?

I tried using my player's player.grid_x and player.grid_y, but nothing is even showing on my screen using love.graphics.print(player.grid_x, 5, 5, 5, 5) etc.

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Thu Aug 21, 2014 7:23 pm
by davisdude
Is the love.graphics.print(...) at the very end of your love.draw() loop? If not, it's probably being drawn over.

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Thu Aug 21, 2014 7:27 pm
by Cryogenical
That worked, thanks!

edit to save double post

My x and my y of the player does get reset, but the character itself is bugging out.
Can someone help?

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Thu Aug 21, 2014 11:23 pm
by Rukiri

Code: Select all

player.act_x = (player.grid_x - 1) * 32
player.act_y = (player.grid_y - 1) * 32
act_x/y never get updated, only initiated! Place that code inside your update, your movement should be continuous if your pressing a directional key not forced to press it every time ya need to move.

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Fri Aug 22, 2014 7:39 pm
by Cryogenical
Rukiri wrote:

Code: Select all

player.act_x = (player.grid_x - 1) * 32
player.act_y = (player.grid_y - 1) * 32
act_x/y never get updated, only initiated! Place that code inside your update, your movement should be continuous if your pressing a directional key not forced to press it every time ya need to move.
Attempted this, didn't work. What should I be setting the original values for act_x/y to be? I've tried 0, 32, and just squares of two.

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Fri Aug 22, 2014 9:29 pm
by Karai17
Act should be the subpixel location of your entity in any given frame, grid should be the tile your entity is "snapped" to.

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Fri Aug 22, 2014 9:32 pm
by Karai17
Also worth noting, you should be using act to draw your entity's location, not grid. This allows for tweening (assuming your entity is grid locked).

Re: Simple Tiled Implementation - STI v0.7.5

Posted: Sat Aug 23, 2014 2:38 am
by Rukiri
Karai17 wrote:Also worth noting, you should be using act to draw your entity's location, not grid. This allows for tweening (assuming your entity is grid locked).
This is kinda what I do, but a lot of my code is ported from game maker. I basically just check the x/y and move on a grid and the grid can be changed to anything, expect 1x1....