Giter Site home page Giter Site logo

About TileViews about pyboy HOT 7 CLOSED

baekalfen avatar baekalfen commented on August 17, 2024
About TileViews

from pyboy.

Comments (7)

Baekalfen avatar Baekalfen commented on August 17, 2024

No worries, I'm glad someone gets some use out of my code :)

If I understand you correctly, you are looking for the type of tiles in the background? Maybe you already know, but tiles are small static "images" of 8x8 pixels, which are placed side-by-side in the background and on the HUD. Sprites on the other hand, can be placed anywhere, and supports transparency — the player is a sprite, as it moves freely. Just to clear any confusion. Sprites are in the view with the blue stripes, and tiles are in the lower window on your screenshot.

I can see that you got the coordinates for the screen and the sprites. From those, you can find the coordinates to look up in the tileviews with getTileView(high). If you set high to true or false, you can switch between the background and HUD.

Remember, that the tileview you get back, contains the indices of the tiles (the corresponding tile is in your lowest window). The tileview is not the framebuffer with pixels in it. You should be able to use get_tile(x, y) to find the tile at the coordinate you provide. x and y go from 0 to 31, as they are the coordinates of a tile, and not the pixel on the screen — you can simply divide the screen pos by 32 8 to find the tile coordinate.

PS.
You can get the framebuffers for the tileviews through the GameWindow instance, but I don't recommend it, as it only works with SDL, its waaay slower, and it might break if I change the code.

Hope this helps :)

from pyboy.

ccokee avatar ccokee commented on August 17, 2024

And how do I know the index number of a given tile? I mean if I do get_tile(10,15) how do I know what tile number is it? Because if I get always the 10,15 tile "normally" each frame would be a different tile and I need something as reference to get decisions depending of what tile is it.
Thanks again. Your code is helping me A LOT.

PS: Shouldn't I divide the screen pos by 8 instead of 32?

from pyboy.

ccokee avatar ccokee commented on August 17, 2024

The thing is Im trying to get what I have inmediately under the player and I get nonsense :S

from pyboy.

Baekalfen avatar Baekalfen commented on August 17, 2024

Have a look at the readme now, I've tried to add a way to determine the indices on screen. Granted, it would be easier to use a tool in the GUI, but this is what I can produce with a short notice.

You're correct, it should be divided by 8!

from pyboy.

ccokee avatar ccokee commented on August 17, 2024

I understand, nevertheless, I am trying to do the maths to convert screen positions to tileview positions, and I found a thing. the screenpos of my game is always at Y=128 (so if screen is 144x128, then 128+128=256, so im watching till the end of the tileview) but, a sprite(the bottom of the mortorcycle) is printed in 128 (it would end in 136) and, under it, I can see 1 tile more (the ground), so, there are 136+8=144 pixels from the piexel Y=128. 128+144=272.. How is this possible if the tileview is 256x256?

from pyboy.

Baekalfen avatar Baekalfen commented on August 17, 2024

That sounds right. As you can see in the tileview on the screenshot, the ground of the player stops at the bottom of the tileview. But on the screen there are two more tiles for the HUD ((128+144)/8 = 34 tiles).

When the screen position overflows the bound of the screen, they simply wrap around to the other side. Meaning; behind the HUD on the screen, are actually rendered to top 2 rows of the left-most tileview, you just cannot see it, as the HUD masks it.

Have a look at page 21 of the report. Figure 22 illustrates exactly this.

EDIT: You can find the real tile x-coordinate by doing: ((x+144)/8)%32 = 2 tiles

from pyboy.

Baekalfen avatar Baekalfen commented on August 17, 2024

Closed because of inactivity.

from pyboy.

Related Issues (20)

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.