|
how does this drawtank function draws a rectangular tank? |
b aryal
Member #17,071
April 2019
|
void drawtank(int num) |
Edgar Reynaldo
Major Reynaldo
May 2007
|
That is allegro 4 code. It draws a tank using filled rectangles only. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
b aryal
Member #17,071
April 2019
|
0: Move toward the northwest context-: if (dir==0...and so on) |
Edgar Reynaldo
Major Reynaldo
May 2007
|
0 is north. You've got to learn how to read code for yourself that's the true mark of a coder, being able to read someone else's code. It has nothing to do with allegro, except that y decreases going up the screen. EDIT If you use <code>code goes here</code> tags, you can highlight your code, and it will provide (outdated) links to the manual, like so : 1void drawtank(int num)
2{
3int x = tanks[num].x;
4int y = tanks[num].y;
5int dir = tanks[num].dir;
6//draw tank body and turret
7rectfill(screen, x-11, y-11, x+11, y+11, tanks[num].color);
8rectfill(screen, x-6, y-6, x+6, y+6, 7);
9//draw the treads based on orientation
10if (dir == 0 || dir == 2)
11{
12rectfill(screen, x-16, y-16, x-11, y+16, 8);
13rectfill(screen, x+11, y-16, x+16, y+16, 8);
14}
15else
16if (dir == 1 || dir == 3)
17{
18rectfill(screen, x-16, y-16, x+16, y-11, 8);
19rectfill(screen, x-16, y+16, x+16, y+11, 8);
20}
21//draw the turret based on direction
22switch (dir)
23{
24case 0:
25rectfill(screen, x-1, y, x+1, y-16, 8);
26break;
27case 1:
28rectfill(screen, x, y-1, x+16, y+1, 8);
29break;
30case 2:
31rectfill(screen, x-1, y, x+1, y+16, 8);
32break;
33case 3:
34rectfill(screen, x, y-1, x-16, y+1, 8);
35break;
36}
37}
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|