Comments (7)
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.
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.
The thing is Im trying to get what I have inmediately under the player and I get nonsense :S
from pyboy.
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.
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.
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.
Closed because of inactivity.
from pyboy.
Related Issues (20)
- Pokemon Red not registering button presses HOT 1
- Error when trying to run with color palette HOT 7
- Pyboy screenshotting function? HOT 2
- Change keybindings HOT 3
- Update build system for Python 3.12
- Street Fighter II screen keeps blinking
- Only show frame-limiting warning when calling set_emulation_speed
- Kirby's Dream Land: Plugin bug HOT 2
- [Enhancement] Expose BG/Obj0/Obj1 Palletes
- Benchmark PyBoy against other emulators
- Create Gameshark plugin [Recommended first issue]
- PyBoy not rendering on remote host over VNC connection HOT 1
- input not working HOT 4
- Failing log statement when not calling pyboy.stop
- GBStudio game stuck on white screen HOT 10
- Windows/macOS: Missing wheels on PyPI HOT 11
- Force clock value HOT 8
- Add RGBDS to install instructions to Wiki HOT 1
- Registering a hook to change PC to the previous instruction doesn't properly advance 'tick'
- Add frame limiter to `null` window HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyboy.