I recommend the Allegro 5 tutorial in the allegro.cc wiki. It teaches you some of the basic functions and explains how allegro works. It helped me to get started with allegro.
@wcake20 I'm having a lot of trouble with it, it tells the basic allegro 5 functions, but I want to load bitmaps(images) for background and some objects, as well as draw numbers on the screen... THEN I will handle events, which is fairly comprehensible for me...
I'm thinking about porting to allegro 4, would you recommend?
You can try the Allegro 5 Manual at allegro.cc / manual/5/ . Look for the functions al_load_bitmap and al_draw_bitmap under "Graphics" (make sure you read the display tutorial first). Drawing numbers is under "Font Addons".
I've experimented Allegro 4 and found it WAY EASIER to "make things work", but as far as event tracking goes, Allegro 5 seems ~way~ superior. I think I'll stick to 5 since logic can be made a lot better, thanks for the tips ;)
My draw functions are completely separate from my game functions (as in, any function that draws images to the screen has absolutely no impact on in-game variables). I only run the draw function if a boolean variable redraw == true. Then I make it such that every 2 counts of the allegro timer (See tutorial), redraw will be set to true. By keeping drawing and other functions separate, you can easily control the frames drawn per second.
what a really stupid game. Never seen something so bad
By now you will have realized that i am speaking sarcastically and i can only hope you finish the game, fantasist graphics, obviously efficient coding, well done!!!!
Well, it's actually finished (although what is displayed here is not the finished version). Or at least I no longer plan to work on this game any more. What's in the download link is the final version and I will be moving on to other games.
First, I made a function(xi, yi, xf, yf) which takes two points and returns the bearing (angle) from the first point to the second point (using the trigonometric functions from math.h). You have to make sure that the function also returns the angle in the correct quadrant.
Use that function to calculate the bearing from the position of the ship to the absolute position of the mouse every frame, then draw a rotated bitmap of the ship.
I did not use pixel collision for this game (I think it would cause too much lag to check collision for each pixel). Instead, I created formulas to detect collision between shapes. I had 2 formulas - one to detect collision between 2 circles (Just check if the distance between the centres is smaller than the sum of their radii), and one to detect collision between a circle and a polygon (the polygons are defined by a set of polar coordinates in anticlockwise order).
Also, since the polygon&circle collision formula is quite complicated, it would cause lag if there were a large number of polygon (including rectangles) bullets in the field at once (because you have to check collision every frame)
Thus, before I apply the collision check formula, I do a much simpler initial check for each object to check whether the object is close enough to bother with the more complicated formula (by giving each object a bounding box slightly larger than the object).
I'm not sure if I should be releasing the source code to public. If you want to know anything about how this game is made, just ask away. It'd be much easier than looking through 600,000 characters of code to figure it out. However, maybe, in future, I could release a source with just the base coding for the game, without the levels coded in (except maybe an example level) for people to mess around with.
@wcake20 okay, I have a question for you: How did you get a sprite for the cursor? Could you possibly msg me the code or tell me what function you called? Thanks!
Since Allegro can detect the position of the mouse on the screen, you can just draw the bitmap of the cursor at the position of the mouse every frame. However, the cursor in my game is not a bitmap. I drew it using allegro primitives. I created a function called sprite_cursor(float x, float y), which draws all the primitives for the cursor relative to the position (x,y). Then, I ran this function every frame with the position of the mouse as x and y.
Each background is split into layers.For the asteroid background, I have the foreground rocks layer, the background rocks layer, and the space/stars layer.
The foremost layer is the most easily drawn. It is drawn the same way as how enemy sprites are drawn. An enemy sprite is drawn by calculating the position of the enemy relative to the screen's position, then drawing it there. The foremost layer bitmap can be imagined to be an enemy sprite that remains at the aboslute position (0,0).
For the other layers, a similar approach is taken, but after you calculate the position of the bitmap relative to the screen's position, you divide that displacement vector by something (e.g. 2), to make it move slower (e.g. twice as slow). This is just the general idea. The actual coding process would take some mathematical skill to get it right.
This game isn't bad!If you know how to code in C++ and DirectX we can get contact and you can code in our company.If you are interested write ma a private message.
If anyone wants, I can explain how I did certain aspects of this game. Things like how I programmed the enemies and their paths, how I made bullets, collision detection, scrolling backgrounds, layered backgrounds, the piercing round / time warp, the minimap, the enemy indicators (red triangles), etc...
Yes, actually! I think that would be helpful. For me, I would like to know how you did the minimap. I like the crisp graphics you have in the game, and I'm impressed by the gameplay.
Making the minimap is pretty simple actually. While sprites in playing field (e.g. enemies, bullets) are drawn relative to the player's position, for the minimap, a circle is instead drawn based on the absolute position of the enemy/player. The size of the playing field is 1200x1200 pixels, and the size of the minimap is 200x200 pixels, so I take the coordinates of the absolute position of the enemy and multiply by (200/1200) to get its position on the minimap.
is just great! i'm doing just like you... starting to learn but maybe ending up doing a little game. If you plan to dedicate to this labor i hope you make it sucessfully! keep it up!
can you please tell me from where you learnt allegro programming......... please do reply
arpit772 1 week ago
@arpit772
There are tutorials online. Easiest way is to read the Allegro 5 tutorials in the Allegro Wiki. You can refer to my other comments for more info.
wcake20 1 week ago
Good work
PeriNKinG 2 weeks ago
Reminds me of geometry wars (my favourate arcade game.) Excellent work!
KawallaBair 2 months ago
Nice job man o_o I have to make a C++ project and chose a game based on Allegro, would you recommend any online tutorial?
Totally loved your game :O
Dan1loBr 3 months ago
@Dan1loBr
I recommend the Allegro 5 tutorial in the allegro.cc wiki. It teaches you some of the basic functions and explains how allegro works. It helped me to get started with allegro.
wcake20 3 months ago
@wcake20 I'm having a lot of trouble with it, it tells the basic allegro 5 functions, but I want to load bitmaps(images) for background and some objects, as well as draw numbers on the screen... THEN I will handle events, which is fairly comprehensible for me...
I'm thinking about porting to allegro 4, would you recommend?
Dan1loBr 3 months ago
@Dan1loBr
You can try the Allegro 5 Manual at allegro.cc / manual/5/ . Look for the functions al_load_bitmap and al_draw_bitmap under "Graphics" (make sure you read the display tutorial first). Drawing numbers is under "Font Addons".
wcake20 3 months ago
@wcake20 Thank you!
I've experimented Allegro 4 and found it WAY EASIER to "make things work", but as far as event tracking goes, Allegro 5 seems ~way~ superior. I think I'll stick to 5 since logic can be made a lot better, thanks for the tips ;)
Dan1loBr 3 months ago
Totally insane, superb, ingenious STG dot
CPPdotCowboj 5 months ago
its great :D do you know how to limit fps in allegro ? i need it :D
furfagns 5 months ago
@furfagns
My draw functions are completely separate from my game functions (as in, any function that draws images to the screen has absolutely no impact on in-game variables). I only run the draw function if a boolean variable redraw == true. Then I make it such that every 2 counts of the allegro timer (See tutorial), redraw will be set to true. By keeping drawing and other functions separate, you can easily control the frames drawn per second.
wcake20 3 months ago
to you...
what a really stupid game. Never seen something so bad
By now you will have realized that i am speaking sarcastically and i can only hope you finish the game, fantasist graphics, obviously efficient coding, well done!!!!
TheOneToxic 5 months ago
@TheOneToxic
Well, it's actually finished (although what is displayed here is not the finished version). Or at least I no longer plan to work on this game any more. What's in the download link is the final version and I will be moving on to other games.
wcake20 3 months ago
awsome work!
pecololek 7 months ago
Wow that's amazing.
Rodaxoleaux 8 months ago
@theTrevorgoo
Unfortanutely no.
I usually play my own music (music from other games) when I play this game.
wcake20 8 months ago
@wcake20 you said you wanted almost everything done by you. You should consider using mario paint composer to make some cool music.
askmiller 4 months ago
@askmiller
Could work, but unfortanutely, I have absolutely no talent in making music.
wcake20 3 months ago
Wow, that is cool. How long did it take you to make? I just finished making pong using allegro 5. :P
Neb1501 8 months ago
@Neb1501
I finished this about 2 months after I started learning allegro / C++.
wcake20 8 months ago
what website did you learn to use allegro in?
blackyurizan 9 months ago
@blackyurizan
Google "allegro 5 tutorial" - I used the allegro wiki tutorial.
It was pretty useful in helping me get started.
After that, it was just a matter of googling what I didn't know.
Also, google "allegro 5 reference manual" - it is a very good reference for the API.
wcake20 9 months ago
This is really cool! Keep it up :] I really like the power ups.
SupraSiegeTower 9 months ago
Wow!! Nice work!! :D
eriklima2 9 months ago
I always wanted to know how to do 2 of the things you did:
1: rotate the sprite according to the mouse position and
2: pixel collision
djsotos 9 months ago
@djsotos Not that I know how to do all the other stuff, like AI, animation etc. but whatever :P
djsotos 9 months ago
@djsotos
1: rotate the sprite according to mouse position.
First, I made a function(xi, yi, xf, yf) which takes two points and returns the bearing (angle) from the first point to the second point (using the trigonometric functions from math.h). You have to make sure that the function also returns the angle in the correct quadrant.
Use that function to calculate the bearing from the position of the ship to the absolute position of the mouse every frame, then draw a rotated bitmap of the ship.
wcake20 9 months ago
@djsotos
2. pixel collision
I did not use pixel collision for this game (I think it would cause too much lag to check collision for each pixel). Instead, I created formulas to detect collision between shapes. I had 2 formulas - one to detect collision between 2 circles (Just check if the distance between the centres is smaller than the sum of their radii), and one to detect collision between a circle and a polygon (the polygons are defined by a set of polar coordinates in anticlockwise order).
wcake20 9 months ago
@djsotos
Also, since the polygon&circle collision formula is quite complicated, it would cause lag if there were a large number of polygon (including rectangles) bullets in the field at once (because you have to check collision every frame)
Thus, before I apply the collision check formula, I do a much simpler initial check for each object to check whether the object is close enough to bother with the more complicated formula (by giving each object a bounding box slightly larger than the object).
wcake20 9 months ago
Very impressive. Are you going to put up the source sometime? :D
sorajsm 10 months ago
@sorajsm
I'm not sure if I should be releasing the source code to public. If you want to know anything about how this game is made, just ask away. It'd be much easier than looking through 600,000 characters of code to figure it out. However, maybe, in future, I could release a source with just the base coding for the game, without the levels coded in (except maybe an example level) for people to mess around with.
wcake20 10 months ago
@wcake20 okay, I have a question for you: How did you get a sprite for the cursor? Could you possibly msg me the code or tell me what function you called? Thanks!
sorajsm 10 months ago
@sorajsm
Since Allegro can detect the position of the mouse on the screen, you can just draw the bitmap of the cursor at the position of the mouse every frame. However, the cursor in my game is not a bitmap. I drew it using allegro primitives. I created a function called sprite_cursor(float x, float y), which draws all the primitives for the cursor relative to the position (x,y). Then, I ran this function every frame with the position of the mouse as x and y.
wcake20 10 months ago
@wcake20 Ok, thanks! How did you get the asteroid background to move? (Closest moves fastest, farthest moves slowest)
sorajsm 9 months ago
@sorajsm
Each background is split into layers.For the asteroid background, I have the foreground rocks layer, the background rocks layer, and the space/stars layer.
The foremost layer is the most easily drawn. It is drawn the same way as how enemy sprites are drawn. An enemy sprite is drawn by calculating the position of the enemy relative to the screen's position, then drawing it there. The foremost layer bitmap can be imagined to be an enemy sprite that remains at the aboslute position (0,0).
wcake20 9 months ago
@sorjasm
For the other layers, a similar approach is taken, but after you calculate the position of the bitmap relative to the screen's position, you divide that displacement vector by something (e.g. 2), to make it move slower (e.g. twice as slow). This is just the general idea. The actual coding process would take some mathematical skill to get it right.
wcake20 9 months ago
This game isn't bad!If you know how to code in C++ and DirectX we can get contact and you can code in our company.If you are interested write ma a private message.
warrockhexer 10 months ago
If anyone wants, I can explain how I did certain aspects of this game. Things like how I programmed the enemies and their paths, how I made bullets, collision detection, scrolling backgrounds, layered backgrounds, the piercing round / time warp, the minimap, the enemy indicators (red triangles), etc...
wcake20 10 months ago
@wcake20
Yes, actually! I think that would be helpful. For me, I would like to know how you did the minimap. I like the crisp graphics you have in the game, and I'm impressed by the gameplay.
VeradoonKing 10 months ago
@VeradoonKing
Making the minimap is pretty simple actually. While sprites in playing field (e.g. enemies, bullets) are drawn relative to the player's position, for the minimap, a circle is instead drawn based on the absolute position of the enemy/player. The size of the playing field is 1200x1200 pixels, and the size of the minimap is 200x200 pixels, so I take the coordinates of the absolute position of the enemy and multiply by (200/1200) to get its position on the minimap.
wcake20 10 months ago
The graphics are clean and fun! I really like all the weapon effects. Nice job!
WreckSector 10 months ago
Very Impressive!
ProgrammerInProgress 10 months ago
That's awesome! Well done!
ultifinitus 11 months ago
is just great! i'm doing just like you... starting to learn but maybe ending up doing a little game. If you plan to dedicate to this labor i hope you make it sucessfully! keep it up!
keyzack 11 months ago