Giter Club home page Giter Club logo

Comments (12)

MateuSai avatar MateuSai commented on June 11, 2024

Hi! I think the problem is that you are using global_position to get the position of the entry Position2D. This would work if the tilemap where at the origin, but that's not the case. set_cellv expects the local coordinate of the tile, that's why we have to use position instead of global_position.

Let me explain further. The tile at the coordinate 0,0 is always at the position of the tilemap. For example, if you have the tilemap at 80,50, the tile at the coordinate 0,0 will start at 80,50, the tile at the coordinate 1,0 will start at 96,50 (considering the tiles are of 16x16). So, in this case we want the coordinate where the entry point is relative to the tilemap.

from godot-roguelike-tutorial.

Todashi999 avatar Todashi999 commented on June 11, 2024

So how do I solve this problem? What do I need to change in the script?
(and thanks for responding)

from godot-roguelike-tutorial.

MateuSai avatar MateuSai commented on June 11, 2024

You need to take the local positions of the entry points instead of the global ones. Use position instead of global_position:

tile_map.set_cellv(tile_map.map_to_world(entry_position.position), 1)
tile_map.set_cellv(tile_map.map_to_world(entry_position.position) + Vector2.DOWN, 2)

from godot-roguelike-tutorial.

Todashi999 avatar Todashi999 commented on June 11, 2024

Thanks! I just tried that - and the walls dont show up. Sorry, I still need some help...

from godot-roguelike-tutorial.

MateuSai avatar MateuSai commented on June 11, 2024

Hmmm, the print you mentioned, did you put it outside the for loop or inside the loop? Could it be the for loop does 0 iterations? If that's the case, check you have the Position2D nodes as children of the entrance node.

Another problem could be the position of the tilemap or the entrance node, do you have the tilemap and entrance node at the position 0,0 of their scene?

If this still does not fix the problem, share the project and I will take a look :)

from godot-roguelike-tutorial.

Todashi999 avatar Todashi999 commented on June 11, 2024

Yeah, it's inside. The position 0,0... How do I share my project with you?

from godot-roguelike-tutorial.

MateuSai avatar MateuSai commented on June 11, 2024

You can compress the project and attach it to your message. Another option is to create a public repository with the project

from godot-roguelike-tutorial.

Todashi999 avatar Todashi999 commented on June 11, 2024

http://localhost:8060/tmp_js_export.html here it is so far
Screen Shot 2023-06-07 at 10 23 40 AM
here is my Room0
and i already showed my code
(sorry idk how to set up a repo)

from godot-roguelike-tutorial.

MateuSai avatar MateuSai commented on June 11, 2024

I can't see anything wrong. Even if you don't create a repo, you should be able to upload the project in a message after you compress it. I don't know how it's done on mac, but normally you right click the folder and then click compress or something like that. Then drag and drop the folder to your message

from godot-roguelike-tutorial.

Todashi999 avatar Todashi999 commented on June 11, 2024

Rougelike.zip

from godot-roguelike-tutorial.

MateuSai avatar MateuSai commented on June 11, 2024

I found the problem, you are using map_to_world instead of world_to_map. map_to_world is used when you want to pass a tile coordinate to pixel coordinates and world_to_map is used when you want to pass a pixel coordinate to tile coordinate. In this case we want to convert the pixel coordinates of the entrance point to tile coordinates, so we must use world_to_map. I should have noticed earlier.

Also, the id of the wall, the wall that fills all the tile, is 1 and the if of the upper wall is 2. You want to put the upper wall on top and the wall that fills a tile below, so, you have to change the tile on top to id 2 and the tile below to id 1:

tile_map.set_cellv(tile_map.world_to_map(entry_position.position), 2)
tile_map.set_cellv(tile_map.world_to_map(entry_position.position) + Vector2.DOWN, 1)

from godot-roguelike-tutorial.

Todashi999 avatar Todashi999 commented on June 11, 2024

Yo man! Thank you so much! That little mistake huh? Thanks for spending your time to help me!

from godot-roguelike-tutorial.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.