Subversion Repositories shark

Rev

Rev 1655 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 giacomo 1
#include <drivers/glib.h>
2
#include "include/draw.h"
3
#include "include/simcity.h"
4
#include "include/states.h"
5
#include "include/misc.h"
6
#define rgb rgb16
7
 
8
void draw_tl(int x,int y,DWORD img[SH][SW]) {
9
  int i,j;
10
 
11
  for(i=0;i<SH;i++) {
12
    for(j=0;j<SW;j++) {
13
      //if(img[i][j]==tl_bg) continue;
14
      grx_plot(x+j,y+i,img[i][j]);
15
    }
16
  }
17
}
18
 
19
void draw_scenario() {
20
   char msg1[35];
21
   int color,fbg;
22
 
23
   color=rgb(235,235,235);
24
   fbg=rgb(198,198,206);
25
   grx_putimage(0,0,799,599,clrscr);
26
   bold_rect(0,0,300,100,0,0,(255-120));
27
   bold_rect(656,102,799,599,(254-120),(255-120),0);
28
   grx_putimage(MAPX,MAPY,MAPX+W-1,MAPY+H-1,street);
29
   bold_rect(0,102,655,599,0,0,(255-120));
30
   bold_rect(301,0,799,100,(255-120),0,0);
31
   grx_box(308,8,791,92,fbg);
32
   grx_text("Alt + x , Enter -> Stop SIMCITY",10,10,color,black);
33
   sprintf(msg1,"c -> Create a new hard car (max %d)",MAX_CAR);
34
   grx_text(msg1,10,20,color,black);
35
   sprintf(msg1,"s -> Create a new soft car (max %d)",MAX_CAR);
36
   grx_text(msg1,10,30,color,black);
37
   grx_text("k -> Kill oldest car",10,40,color,black);
38
   grx_text("r -> Refresh screen",10,50,color,black);
39
   grx_text("d -> Toggle sensor",10,60,color,black);
40
   grx_text("road  spd",CAMX,CAMY-10,gray,black);
41
   grx_text("Simcity is presented by",450,20,black,fbg);
42
   grx_text("     Aguzzi Marco",450,50,rgb(200,140,5),fbg);
43
   grx_text("           &",450,60,black,fbg);
44
   grx_text("     Ferrari Fabio",450,70,rgb(120,40,226),fbg);
45
   drawFaces(390,15,0);
46
   drawFaces(640,15,1);
47
}
48
 
49
void bold_rect(WORD x1,WORD y1,WORD x2,WORD y2,BYTE r,BYTE g,BYTE b) {
50
 int c1,c2,c3,c4;
51
 
52
 if(r>=255) r=255;
53
  if(g>=255) g=255;
54
  if(b>=255) b=255;
55
 
56
  c1=rgb(r,g,b);
57
  c2=rgb((r+40),(g+40),(b+40));
58
  c3=rgb((r+80),(g+80),(b+80));
59
  c4=rgb((r+120),(g+120),(b+120));
60
  grx_rect(x1,y1,x2,y2,c1);
61
  grx_rect((x1+1),(y1+1),(x2-1),(y2-1),c2);
62
  grx_rect((x1+2),(y1+2),(x2-2),(y2-2),c3);
63
  grx_rect((x1+3),(y1+3),(x2-3),(y2-3),c4);
64
  grx_rect((x1+4),(y1+4),(x2-4),(y2-4),c4);
65
  grx_rect((x1+5),(y1+5),(x2-5),(y2-5),c3);
66
  grx_rect((x1+6),(y1+6),(x2-6),(y2-6),c2);
67
  grx_rect((x1+7),(y1+7),(x2-7),(y2-7),c1);
68
}
69
 
70
void drawCar(int x,int y,int angle,char mode) {
71
        int i,j;
72
 
73
        for (i=0;i<ROW;i++) {
74
                for (j=0;j<COL;j++) {
75
      if (macchine[i][j][returnCarIndex(angle)]!=0) {
76
        grx_plot(x+j-15,y+i-15,macchine[i][j][returnCarIndex(angle)]*mode);
77
                        }
78
                }
79
        }
80
}
81
 
82
 
83
void get_images() {
84
 
85
  grx_getimage(0,0,799,599,clrscr);
86
  drawStreet(0,0);
87
  grx_getimage(0,0,639,479,street);
88
  grx_putimage(0,0,799,599,clrscr);
89
  grx_getimage(0,0,31,31,clrcam);
90
  drawSprites(15,15,GAUGE,DRAW);
91
  grx_getimage(0,0,29,29,gauge_img);
92
  grx_putimage(0,0,30,30,clrcam);
93
  drawSprites(15,15,ARR_OFF,DRAW);
94
  grx_getimage(0,0,29,29,arrow[1]);
95
  grx_putimage(0,0,30,30,clrcam);
96
  drawSprites(15,15,ARR_SX,DRAW);
97
  grx_getimage(0,0,29,29,arrow[2]);
98
  grx_putimage(0,0,30,30,clrcam);
99
  drawSprites(15,15,ARR_DX,DRAW);
100
  grx_getimage(0,0,29,29,arrow[0]);
101
  grx_putimage(0,0,30,30,clrcam);
102
  drawSprites(15,15,GAUGE_ROTTO,DRAW);
103
  grx_getimage(0,0,29,29,brk_gauge);
104
  grx_putimage(0,0,30,30,clrcam);
105
 
106
}
107
 
108
void drawStreet(int x,int y) {
109
        int i,j;
110
 
111
  for (i=0;i<H;i++) {
112
    for (j=0;j<W;j++) {
113
      grx_plot(x+j,y+i,strada[i][j]);
114
                }
115
        }
116
}
117
 
118
void drawSprites(int x,int y,char number,char mode) {
119
        int i,j;
120
 
121
  for (i=0;i<ROW;i++) {
122
    for (j=0;j<COL;j++) {
123
      if (sprites[i][j][(int)number]!=0) {
124
        grx_plot(x+j-15,y+i-15,sprites[i][j][(int)number]*mode);
125
      }
126
                }
127
        }
128
}
129
 
130
void drawFaces(int x,int y,short face) {
131
        int i,j;
132
 
133
  for (i=0;i<74;i++) {
134
    for (j=0;j<47;j++) {
135
      grx_plot(x+j,y+i,faces[face][i][j]);
136
                }
137
        }
138
}
139