I plan on using this thread to recieve help for many different problems in allegro. I will ask 1 by 1.
Prob Num 1:
Can I get an example ( with comments) of a program that will take your Sprite.bmp and put it on screen?
I plan on using this thread to recieve help for many different problems in allegro. I will ask 1 by 1.
Prob Num 1:
Can I get an example ( with comments) of a program that will take your Sprite.bmp and put it on screen?
What is C++?
Did that sprite code I sent you work?
gcc -lalleg
http://www.ciusa.net/~jrgrant/
look at your PM
What is C++?
Thanks Josh for helpin me there.
Now
Num 2:
How can I make the ship move, and not leave a trail?Code:#include <allegro.h> int x = 300, quit = 0; int main() { allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0); BITMAP *ship = load_bitmap( "Ship.bmp", NULL ); while ( !quit ) { if ( keypressed() ){ if ( key[KEY_LEFT] ) x--; else if ( key[KEY_ESC] ) quit = 1; } draw_sprite ( screen, ship, x, 400 ); } destroy_bitmap(ship); allegro_exit(); return 0; } END_OF_MAIN();
Also why does it move so freakin fast?
Last edited by Vicious; 06-05-2002 at 09:12 PM.
What is C++?
You have to use dirty rectangles (i think) or clear the screen. Clearing the screen would be slow, and cause alot of flicker. I will try to code an example of how to move a sprite with no flicker in a little bit.
gcc -lalleg
http://www.ciusa.net/~jrgrant/
i know almost nothing about allegro, but from expereince in other apis, your ship is leaving a trail because youre not erasing it. you can expecet the stupid box in front of you to know when to clear something.
I might be able ( with josh's help ) to find a function for this.
But my problem is if i barely tap LEFT it flys of the flippin' screen!
Here is what I think is happening:
It detects the LEFT key and makes x++, but when it loops back, it continues to x++.
What is C++?
either that, or youre not checking the key every time you loop. try printing to a file or something what you get as input on every loop. also, arent there delay functions in allegro(for slowing down the movement of the ship)?
After you get the input and change the coordinates, try something simple like for(int j = 0; j < 400; j++) ;
gcc -lalleg
http://www.ciusa.net/~jrgrant/
nope, makes no difference what so ever
What is C++?
I was looking in the Allegro docs and found this:
void set_keyboard_rate(int delay, int repeat);
Try setting it before your loop. Set is after install_keyboard();.
Mess around with the parameters till it works right.
gcc -lalleg
http://www.ciusa.net/~jrgrant/
i was 1 or 2 steps ahead of you. I tried
set_keyboard_rate(0, 0)
that is supposed to disable it but it didnt work
im gonna try 1, 1 now
edit: nope
What is C++?
Hmm, I do not know, but this may fix it, after you change the coordinates and redraw the sprite put clear_keybuf();
gcc -lalleg
http://www.ciusa.net/~jrgrant/
i just finished a game in allegro and this i what i did to conrol game speed. you update the screen and keyboard input every loop, but you only change the objects position after so much time. heres an ex.
Code:#include <time.h> clock_t time1,time2; int main() time1 = clock(); while (key[KEY_ESC==0])) { clear(screen); keyboard_input update_screen time2 = clock(); if (time2-time1>100) //makes this # bigger to slow down { move object time1 = clock(); } } return;
what is update_screen?
And i really didnt want to go this route...
I dont want flicker in my game
What is C++?