![]() |
|
|||||||
Accueil |
S'inscrire |
FAQ |
Glossaire |
Membres |
Calendrier |
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: 04/09/2007
Messages: 15
|
Hello (or Bonjour, as you wish
)Well, i'm having some problems with pad system of OSL, with osl_pad.released one to be precise (althought i think it's all because of my poor programming skills...). I'm trying to make a moving arrow that will move on itself and will stop moving after releasing the cross. The function looks like this: Code:
void BouncyImage::moveBump(){
if(osl_pad.released.cross){
if(isBumping == false){
isBumping =true;
}
else{
isBumping = false;
}
}
//the (quite long) rest is about moving and all...
}
there is the whole main.cpp source. So, althought i think one of possibilities of this error is because the rest of function is quite long... Yet, it's not possible to make some more checks in the function. So, is there any way to get rid if this problem? And quite an offtopic question that i'd like to know the anwser: how does the library know if the button has been held, pushed or just released? I'm still new to programming, so please forgive me those little mistakes ![]() |
|
|
|
| Publicité |
|
|
#2 |
|
Administrateur
Date d'inscription: 09/11/2005
Messages: 3 738
|
But what is your problem ?
Sorry I don't understand... If you want : "make a moving arrow that will move on itself and will stop moving after releasing the cross", use osl_pad.held : Code PHP:
|
|
|
|
|
|
#3 |
|
Membre
Date d'inscription: 04/09/2007
Messages: 15
|
Oh god, i forgot to say what the problem is!
Well, the thing is, that pressing X works only sometimes, usually nothing happens ![]() |
|
|
|
|
|
#4 |
|
Membre
Date d'inscription: 04/09/2007
Messages: 15
|
Well, there is still a big problem with pad.released and pad.pressed. I'm actually "trying"
to make a galaga-like game. And so, i made a function that makes ship shoot a bullet when X button is...Well, it only works when X is checked with osl_pad.held.cross. When i'm trying to check if the button is pressed or released, it looks like it doesn't work! The ship shoots the bullet only if X is held. So, what is the problem and how to solve it? |
|
|
|
|
|
#5 |
|
Super Modérateur
Date d'inscription: 10/11/2005
Localisation: Un pays avec beaucoup de banques
Messages: 3 188
|
The problem is probably in your code because if the X key didn't work properly, a lot of other people (including me) would have noticed it
![]() What does it look like?
__________________
[21.01.2010] Emu Game Boy et GUI pour la coloration de jeux GB Mes projets: c'est ici. Partagez vos meilleures musiques de jeu vidéo!
|
|
|
|
|
|
#6 |
|
Administrateur
Date d'inscription: 09/11/2005
Messages: 3 738
|
I think that the problem is in your code, not with oslib
![]() |
|
|
|
|
|
#7 |
|
Membre
Date d'inscription: 04/09/2007
Messages: 15
|
http://rapidshare.com/files/60694391/Ast.rar.html
Well, there's the source, and tehgame itself... Crappy, but somewhat works... 'cept that problem ![]() And the code looks like that: In main.c the engine is initialized, and the SetKeyAutorepeat looks like: Code:
oslSetKeyAutorepeatInit(40);
oslSetKeyAutorepeatInterval(10);
Them in the main loop, the gameScreen.createScreen(); is called. Within this function, lies: Code:
void gameScreen::createScreen(){
itsShip.checkMovement();
itsEnemyArray.moveArray();
itsShip.moveBullet(-1);
}
). Then, within itsShip.moveBullet(-1); lies the problematic part.Code:
void ship::moveBullet(int Vector){
oslReadKeys();
bool breaker = false;
if(osl_pad.released.cross){
for(int iCounter = 0; iCounter < 3;iCounter++){
if(itsBullet[iCounter].retMovement() == false){
itsBullet[iCounter].createBullet("bullet.png",itsX + 3,itsY);
breaker = true;
}
if(breaker == true)
break;
}
}
for(int i = 0; i < 3; i++){
itsBullet[i].move(Vector);
}
}
.And that's all... To be frank, same problem appeared in the previous, much simpler project ![]() |
|
|
|
|
|
#8 | |
|
Administrateur
Date d'inscription: 09/11/2005
Messages: 3 738
|
It's hard to understand this damn C++ syntax
![]() But try to delete the 2nd "oslReadKeys();" at l.126... oslReadKeys must be called only once. I didn't tested it, but try a look. And this will do not work : Citation:
![]() |
|
|
|
|
|
|
#9 |
|
Membre
Date d'inscription: 04/09/2007
Messages: 15
|
Deleting the second call of function helped a lot
Thank you, Yodajr!And also, a question -> was that syntax illegilible because you are more fluent with c or was my messy style of writing the reason? ![]() |
|
|
|
|
|
#10 |
|
Administrateur
Date d'inscription: 09/11/2005
Messages: 3 738
|
You're welcome
![]() And don't worry, it's because I learned only C ![]() |
|
|
|
![]() |
| Liens sociaux |
| Publicité |
| Utilisateurs regardant la discussion actuelle : 1 (0 membre(s) et 1 invité(s)) | |
| Outils de la discussion | |
| Modes d'affichage | |
|
|