Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: Simple Tiled Implementation - STI v0.7.5

Post by Cryogenical » Thu Aug 21, 2014 6:24 pm

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?

User avatar
Rukiri
Citizen
Posts: 68
Joined: Mon Jun 27, 2011 5:52 am

Re: Simple Tiled Implementation - STI v0.7.5

Post by Rukiri » Thu Aug 21, 2014 6:28 pm

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.

User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: Simple Tiled Implementation - STI v0.7.5

Post by Cryogenical » Thu Aug 21, 2014 7:21 pm

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.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Simple Tiled Implementation - STI v0.7.5

Post by davisdude » Thu Aug 21, 2014 7:23 pm

Is the love.graphics.print(...) at the very end of your love.draw() loop? If not, it's probably being drawn over.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: Simple Tiled Implementation - STI v0.7.5

Post by Cryogenical » Thu Aug 21, 2014 7:27 pm

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?
Attachments
LoveTiled.love
(6.65 MiB) Downloaded 76 times

User avatar
Rukiri
Citizen
Posts: 68
Joined: Mon Jun 27, 2011 5:52 am

Re: Simple Tiled Implementation - STI v0.7.5

Post by Rukiri » Thu Aug 21, 2014 11:23 pm

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.

User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: Simple Tiled Implementation - STI v0.7.5

Post by Cryogenical » Fri Aug 22, 2014 7:39 pm

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.

User avatar
Karai17
Party member
Posts: 903
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.7.5

Post by Karai17 » Fri Aug 22, 2014 9:29 pm

Act should be the subpixel location of your entity in any given frame, grid should be the tile your entity is "snapped" to.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
Karai17
Party member
Posts: 903
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.7.5

Post by Karai17 » Fri Aug 22, 2014 9:32 pm

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).
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
Rukiri
Citizen
Posts: 68
Joined: Mon Jun 27, 2011 5:52 am

Re: Simple Tiled Implementation - STI v0.7.5

Post by Rukiri » Sat Aug 23, 2014 2:38 am

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....

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests