![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Ouvrir sur le forum | Recherche | Messages du jour | Marquer les forums comme lus |
Aide au développement Aide sur l'utilisation d'OSLib |
Publicité |
![]() |
|
Outils de la discussion | Modes d'affichage |
![]() |
#1 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() 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 ![]() |
![]() |
![]() |
Publicité |
![]() |
#2 |
Administrateur
Date d'inscription: 09/11/2005
Messages: 3 750
|
![]() http://www.playeradvance.org/forum/s...ad.php?t=23112
PS : forget about internet translation please, it is incomprehensible ![]() |
![]() |
![]() |
![]() |
#3 |
Administrateur
|
![]() 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....
__________________
Projets Abandonnés: [Arcomage Advance] [Puzznic] [PA Card Games] [Blob Runner] Projet en cours: [Ne plus abandonner de projet...] |
![]() |
![]() |
![]() |
#4 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() So would it be like this:
Code:
#define TILE_SOLID 1 #define TILE_NONSOLID 2 TILE_SOLID = RGB(0,0,124); TILE_NONSOLID = RGB(255,0,244); // and then make the collision using these variables |
![]() |
![]() |
![]() |
#5 |
Administrateur
|
![]() no, if you have a map like that:
Code:
#define TILE_SOLID 1 // 0x0001 #define TILE_NONSOLID 2 // 0x0002 const unsigned short example_map[8][13]= { {0x0001, 0x0002, 0x0002, 0x0001, 0x0001,... .... Code:
example_map[x][y] == TILE_SOLID
__________________
Projets Abandonnés: [Arcomage Advance] [Puzznic] [PA Card Games] [Blob Runner] Projet en cours: [Ne plus abandonner de projet...] |
![]() |
![]() |
![]() |
#6 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() 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 ![]() Map ![]() Oh and I convert my maps using GBA graphics |
![]() |
![]() |
![]() |
#7 |
Administrateur
|
![]() 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
__________________
Projets Abandonnés: [Arcomage Advance] [Puzznic] [PA Card Games] [Blob Runner] Projet en cours: [Ne plus abandonner de projet...] |
![]() |
![]() |
![]() |
#8 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() O.K. here is my collisions_map.h
Code:
//C:\Users\Pspmasterpro\Desktop\lv1_collsions.png //Converti avec GBA Graphics par Brünni //Map ("","C:\Users\Pspmasterpro\Desktop\lv1_collsions.til.c",0,ffffffff) //Taille: 32*32 * 60*9 //Mémoire: 1080 octets const unsigned short LVCollision1_map[9][60]= { {0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0004, 0x0005, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003}, {0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0007, 0x0005, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003}, {0x0000, 0x0000, 0x0000, 0x0000, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0009, 0x0005, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003}, {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x000a, 0x0005, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000b, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0003}, {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000b, 0x000c, 0x000d, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000e, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x000f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003}, {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0011, 0x000b, 0x0008, 0x000c, 0x000d, 0x0008, 0x000a, 0x0000, 0x0010, 0x0003, 0x0003, 0x0003, 0x0003, 0x0011, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000b, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003}, {0x0000, 0x0010, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0000, 0x0005, 0x0006, 0x0000, 0x0000, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0012, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003}, {0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0000, 0x0005, 0x0006, 0x0000, 0x0000, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0013, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003}, {0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0000, 0x0005, 0x0006, 0x0000, 0x0000, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0014, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003} }; Code:
#define TILE_SOLID 1 // 0x0001 #define TILE_NONSOLID 2 // 0x0002 const unsigned short example_map[8][13]= { {0x0001, 0x0002, 0x0002, 0x0001, 0x0001,... .... I've attatched both the tileset and map images in case you can't see them. |
![]() |
![]() |
![]() |
#9 |
Administrateur
|
![]() 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
__________________
Projets Abandonnés: [Arcomage Advance] [Puzznic] [PA Card Games] [Blob Runner] Projet en cours: [Ne plus abandonner de projet...] |
![]() |
![]() |
![]() |
#10 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() O.K. I used tile precision and I re-did my map so it only has 2 tiles in the tileset and it works
![]() 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:
{......} void newGame() { int RLimit = 250; int LLimit = 50; oslReadKeys(); oslCls(); // Draw map and player oslDrawMap(mapCollision1); oslDrawImage(player); // Character movement with camera and collision detection if(osl_keys->held.right && !collisionMgr(mapCollision1,player,0,1,0,0)) { if (player->x >= RLimit) { map1->scrollX += 1.3; mapCollision1->scrollX += 1.3; } else { player->x += 1.3; } } if(osl_keys->held.left && !collisionMgr(mapCollision1,player,1,0,0,0)) { if (player->x <= LLimit) { map1->scrollX -= 1.3; mapCollision1->scrollX -= 1.3; } else { player->x -= 1.3; } } } {......} short GetTile(OSL_MAP *m,int col, int row) { u16 *map = (u16*)m->map; return map[row*m->mapSizeX + col]; } {......} int collisionMgr(OSL_MAP *m, OSL_IMAGE *Collision, int left, int right, int top, int bottem) { #define TILE_NONSOLID 0x0000 #define TILE_SOLID 0x0001 int tile; if(left) { tile = GetTile(m,((m->scrollX + Collision->x - 0))/ m->tileX, (m->scrollY + Collision->y + Collision->stretchY)/ m->tileY); if (!tile) { tile = GetTile(m,((m->scrollX + Collision->x - 0))/ m->tileX, (m->scrollY + Collision->y)/ m->tileY); } } if(right) { tile = GetTile(m,((m->scrollX + Collision->x +Collision->stretchX + 0))/ m->tileX, (m->scrollY + Collision->y + Collision->stretchY)/ m->tileY); if (!tile) { tile = GetTile(m,((m->scrollX + Collision->x +Collision->stretchX + 0))/ m->tileX, (m->scrollY + Collision->y)/ m->tileY); } } if(top) { tile = GetTile(m,((m->scrollX + Collision->x +Collision->stretchX ))/ m->tileX, (m->scrollY + Collision->y - 0)/ m->tileY); if (!tile) { tile = GetTile(m,((m->scrollX + Collision->x))/ m->tileX, (m->scrollY + Collision->y - 0)/ m->tileY); } } if(bottem) { tile = GetTile(m,((m->scrollX + Collision->x +Collision->stretchX ))/ m->tileX, (m->scrollY + Collision->y + Collision->stretchY + 0)/ m->tileY); if (!tile) { tile = GetTile(m,((m->scrollX + Collision->x))/ m->tileX, (m->scrollY + Collision->y + Collision->stretchY + 0)/ m->tileY); } } switch(tile) { case TILE_NONSOLID: return 0; break; case TILE_SOLID: return 1; break; } return 0; } {......} |
![]() |
![]() |
![]() |
#11 |
Administrateur
|
![]() 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...
__________________
Projets Abandonnés: [Arcomage Advance] [Puzznic] [PA Card Games] [Blob Runner] Projet en cours: [Ne plus abandonner de projet...] |
![]() |
![]() |
![]() |
#12 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() 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() { int RLimit = 250; int LLimit = 50; int canJump = 1; oslReadKeys(); oslCls(); // Draw map and player oslDrawMap(mapCollision1); oslDrawImage(player); // Active gravity if(!collisionMgr(mapCollision1,player,0,0,0,1) && canJump == 1) { player->y += 1; } else if(collisionMgr(mapCollision1,player,0,0,0,1)) { canJump = 1; } // Character movement with camera and collision detection if(osl_keys->held.right && !collisionMgr(mapCollision1,player,0,1,0,0)) { if (player->x >= RLimit) { map1->scrollX += 1; mapCollision1->scrollX += 1; } else { player->x += 1; } } if(osl_keys->held.left && !collisionMgr(mapCollision1,player,1,0,0,0)) { if (player->x <= LLimit) { map1->scrollX -= 1; mapCollision1->scrollX -= 1; } else { player->x -= 1; } } if(osl_keys->pressed.cross && !collisionMgr(mapCollision1,player,0,0,1,0)) { if(canJump == 1) canJump = 0; player->y -= 3; } } ![]() Dernière modification par pspmasterpro ; 21/02/2009 à 02h28. |
![]() |
![]() |
![]() |
#13 |
Administrateur
|
![]() 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
__________________
Projets Abandonnés: [Arcomage Advance] [Puzznic] [PA Card Games] [Blob Runner] Projet en cours: [Ne plus abandonner de projet...] |
![]() |
![]() |
![]() |
#14 |
Membre
Date d'inscription: 22/01/2009
Messages: 17
|
![]() Thanks I removed oslReadKeys(); from newGame and pressed works. O.K. for my next question I'll make a new thread.
|
![]() |
![]() |
![]() |
Liens sociaux |
Publicité |
Utilisateurs regardant la discussion actuelle : 1 (0 membre(s) et 1 invité(s)) | |
Outils de la discussion | |
Modes d'affichage | |
|
|
![]() |
||||
Discussion | Auteur | Forum | Réponses | Dernier message |
![]() ![]() |
Albandu51 | Aide au développement | 1 | 17/12/2008 12h05 |
![]() ![]() |
morukutsu | µLibrary | 7 | 09/04/2008 02h45 |
![]() ![]() |
dragfly | Aide au développement | 1 | 13/02/2008 22h03 |
[oslib] petite question: collisions | norfair | Aide au développement | 13 | 20/01/2007 20h19 |
Pixel mort... ou pas ? | katrinien | [NDS] Divers | 33 | 15/08/2006 20h40 |