![]() |
[OSLIB] Get pixel question
Hello I saw a few topics regarding this and I have a few questions about the get pixel, can oslib read an entire image and see if some pixels are of a specified color. I'm trying to create a collision detection using tile maps. EG: say I have blue and pink tiles I want the blue tiles to be solid and pink to be non solid. My Question is, can oslib read every pixel of the image to check if it's blue or pink and then apply it to the map for the collisions?
Thanks for your help :) Bonjour j'ai vu que quelques matières concernant ceci et moi ont quelques questions au sujet du Pixel d'obtention, peuvent oslib lisent une image entière et voient si quelques Pixel sont d'une couleur spécifique. I' ; m essayant de créer une détection de collision utilisant la tuile trace. PAR EXEMPLE : dites j'ai les tuiles bleues et roses que je veux que les tuiles bleues soient pleines et roses pour être non plein. Ma question est, peut oslib a lu chaque Pixel de l'image pour vérifier s'it' ; s bleu ou rose et s'appliquent alors l'à la carte pour les collisions ? Merci pour votre aide :) |
http://www.playeradvance.org/forum/s...ad.php?t=23112
PS : forget about internet translation please, it is incomprehensible ;) |
for collision system using tiles precision and not pixel, you can just check the index of the tile.
Example: in your tileset, index are: blue = 1 and red = 2 so when you read your map you can know what tile it is. Not sure to be clear.... |
So would it be like this:
Code:
#define TILE_SOLID 1 |
no, if you have a map like that:
Code:
Code:
example_map[x][y] == TILE_SOLID |
O.K. But my tile set and map are like this so do I have to create multipal example_map[x][y] == TILE_SOLID collision checks for each section of my map? Or can I replace X and Y with the entire map size and it will check the entire map?
Tileset http://i208.photobucket.com/albums/b...on_tileset.png Map http://i208.photobucket.com/albums/b..._collsions.png Oh and I convert my maps using GBA graphics |
hum sorry I can see your screenshot cause of a fucking proxy...... will see it at home
but if you want to check the position of a sprite, you take its coordonates (at pixel precision) and make a function to get the position on the map (something like x/8...) and when you have the map position of the sprite you can check the type of tile at this position and do your stuff |
2 pièce(s) jointe(s)
O.K. here is my collisions_map.h
Code:
//C:\Users\Pspmasterpro\Desktop\lv1_collsions.png Code:
#define TILE_SOLID 1 // 0x0001 I've attatched both the tileset and map images in case you can't see them. |
yes, again I ask the question: do you want pixel precision or tile precision ??
if it is tile, yes you need to add more define, not just solid/nonsolid if it is pixel, you can by example (not sure if it is the best method) get the tile index from the map and then take the tile from your tileset and then check the pixel in the tile |
O.K. I used tile precision and I re-did my map so it only has 2 tiles in the tileset and it works :D
my question is: is it possible to create platformer physics like Jumping with this method of collision. In a platformer you can jump and gravity acts on the faller so the player falls and it's fall increases and stops when the player hits the tile I know that Super Patrick II has this but it's in french so is their another method to do this? Here is my collision code so far: *I used tutorial 10 for help* Code:
{......} |
hum it's difficult to help you like that, but maybe you must replace - 0 by some value, cause perhaps you are testing the tile where you are instead of the tile at the left of the player
I think you must add some debug trace (oslPrintf etc...) to check that your code do the right stuff and the last thing, the value 1.3 do nothing because it is int type... |
Thanks, I changed the 1.3 value to 1 and replaced -0 with -1 and I resized my character to 30 by 30 and it works well. I have another problem, in my game function I can't seam to use osl_keys->pressed I can only use osl_keys->held. Example here is my newGame function:
Code:
void newGame() |
First thing, it is better to open different threads on the forum if it is different problem for helping other member in the future
Then add else if for your key input, it is always better to use else if if it is exclusive cases. And for your problem maybe canJump = 0, so press X do nothing... add oslDebug to be sure X pressed is detect |
Thanks I removed oslReadKeys(); from newGame and pressed works. O.K. for my next question I'll make a new thread.
|
Fuseau horaire GMT +2. Il est actuellement 12h44. |
Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd. Tous droits réservés.
Version française #16 par l'association vBulletin francophone