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?
Simple Tiled Implementation - STI v1.2.3.0
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.5
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.
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.
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.5
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.
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
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
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.5
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?
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 212 times
Re: Simple Tiled Implementation - STI v0.7.5
Code: Select all
player.act_x = (player.grid_x - 1) * 32
player.act_y = (player.grid_y - 1) * 32
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: Simple Tiled Implementation - STI v0.7.5
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.Rukiri wrote: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.Code: Select all
player.act_x = (player.grid_x - 1) * 32 player.act_y = (player.grid_y - 1) * 32
Re: Simple Tiled Implementation - STI v0.7.5
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é
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.7.5
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é
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.7.5
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....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).
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests