Browse Source

Add color field to object definitions

Marrub 1 year ago
parent
commit
6b63f235af
6 changed files with 47 additions and 26 deletions
  1. 2
    1
      data/objdefs/testobj.dod
  2. 1
    1
      data/resdecl.rd
  3. 16
    16
      maps/stage1.gmf9
  4. 20
    8
      src/g_objdef.c
  5. 5
    0
      src/g_objdef.h
  6. 3
    0
      src/g_player.c

+ 2
- 1
data/objdefs/testobj.dod View File

@@ -2,10 +2,11 @@
2 2
 entity TestObj
3 3
 {
4 4
    subtype Test
5
-   health 1
5
+   health 6
6 6
    size 10
7 7
    drawsize 16
8 8
    sprite "ent/testobj"
9
+   color 1, 0, 0
9 10
 }
10 11
 
11 12
 // EOF

+ 1
- 1
data/resdecl.rd View File

@@ -5,7 +5,7 @@ font "place" = "fonts/base.ttf", 30pt
5 5
 texture "gui/border"     = "textures/Border.png"
6 6
 texture "gui/playerback" = "textures/PlayerBack.png"
7 7
 
8
-texture "ent/testobj"    = "sprites/Particle3.png"
8
+texture "ent/testobj"    = "sprites/Particle2.png"
9 9
 texture "ent/explosion1" = "sprites/Explosion1.png"
10 10
 texture "ent/explosion2" = "sprites/Explosion2.png"
11 11
 texture "ent/explosion3" = "sprites/Explosion3.png"

+ 16
- 16
maps/stage1.gmf9 View File

@@ -1,19 +1,19 @@
1 1
 // Copyright © 2017 Project Golan, all rights reserved.
2
-{ 50 TestObj -300 -200 16}
3
-{ 60 TestObj -250 -200 16}
4
-{100 TestObj -150 -200 16}
5
-{110 TestObj -100 -200 16}
6
-{150 TestObj -200 -200 16}
7
-{160 TestObj -250 -200 16}
8
-{200 TestObj -300 -200 16}
9
-{210 TestObj -250 -200 16}
10
-{250 TestObj -300 -200 16}
11
-{260 TestObj -250 -200 16}
12
-{300 TestObj -150 -200 16}
13
-{310 TestObj -100 -200 16}
14
-{350 TestObj -200 -200 16}
15
-{360 TestObj -250 -200 16}
16
-{400 TestObj -300 -200 16}
17
-{410 TestObj -250 -200 16}
2
+{ 50 TestObj -300 -340 17}
3
+{ 60 TestObj -250 -340 17}
4
+{100 TestObj -150 -340 17}
5
+{110 TestObj -100 -340 17}
6
+{150 TestObj -200 -340 17}
7
+{160 TestObj -250 -340 17}
8
+{200 TestObj -300 -340 17}
9
+{210 TestObj -250 -340 17}
10
+{250 TestObj -300 -340 17}
11
+{260 TestObj -250 -340 17}
12
+{300 TestObj -150 -340 17}
13
+{310 TestObj -100 -340 17}
14
+{350 TestObj -200 -340 17}
15
+{360 TestObj -250 -340 17}
16
+{400 TestObj -300 -340 17}
17
+{410 TestObj -250 -340 17}
18 18
 
19 19
 // EOF

+ 20
- 8
src/g_objdef.c View File

@@ -87,6 +87,7 @@ typedef union G_odprm
87 87
    integ i;
88 88
    fixed k;
89 89
    lfrac r;
90
+   ulfra R;
90 91
 } G_odprm;
91 92
 
92 93
 typedef struct G_odarg
@@ -223,12 +224,14 @@ static G_odarg G_ObjDef_getArgs(G_dodst *st, char const *arg)
223 224
             a.argv[a.argc++].t = \
224 225
                f(st->expect(tok_number, "number")->textV, __VA_ARGS__); \
225 226
             break
226
-      CaseN('u', u, strtoui,   NULL, 0);
227
-      CaseN('i', i, strtoi,    NULL, 0);
228
-      CaseN('k', k, strtofxhk, NULL);
229
-      CaseN('r', r, strtofxlk, NULL);
230
-      // TODO: get david to implement fracts
231
-      //CaseN('r', r, strtofxlr, NULL);
227
+      CaseN('u', u, strtoui,    NULL, 0);
228
+      CaseN('i', i, strtoi,     NULL, 0);
229
+      CaseN('k', k, strtofxhk,  NULL);
230
+      // TODO: replace when strtofxr* is added
231
+      CaseN('r', r, strtod, NULL);
232
+      CaseN('R', R, strtod, NULL);
233
+      //CaseN('r', r, strtofxlr,  NULL);
234
+      //CaseN('R', R, strtofxulr, NULL);
232 235
       #undef CaseN
233 236
       case  '|': done = true; continue;
234 237
       case '\0': st->throw("too many arguments");
@@ -282,12 +285,10 @@ static void G_ObjDef_getEntProp(G_dodst *st, G_enttype *type, char const *id)
282 285
       G_odarg a = st->getArgs("k|kk");
283 286
       if(a.argc == 1) {
284 287
          type->sx = type->sy = a.argv[0].k;
285
-         type->sz = 16;
286 288
       } else {
287 289
          type->sx = a.argv[0].k;
288 290
          type->sy = a.argv[1].k;
289 291
          if(a.argc > 2) type->sz = a.argv[2].k;
290
-         else           type->sz = 16;
291 292
       }
292 293
    }
293 294
    else if(strcmp(id, "drawsize") == 0)
@@ -300,6 +301,14 @@ static void G_ObjDef_getEntProp(G_dodst *st, G_enttype *type, char const *id)
300 301
          type->rsy = a.argv[1].k;
301 302
       }
302 303
    }
304
+   else if(strcmp(id, "color") == 0)
305
+   {
306
+      G_odarg a = st->getArgs("R|RRR");
307
+                     type->cr = a.argv[0].R;
308
+      if(a.argc > 1) type->cg = a.argv[1].R;
309
+      if(a.argc > 2) type->cb = a.argv[2].R;
310
+      if(a.argc > 3) type->ca = a.argv[3].R;
311
+   }
303 312
    else if(strcmp(id, "sprite") == 0)
304 313
    {
305 314
       type->sprite = DGE_Texture_Get(
@@ -449,6 +458,9 @@ static void G_ObjDef_parseEntDef(G_dodst *st)
449 458
       }
450 459
    }
451 460
 
461
+   decl->type.sz = 16;
462
+   decl->type.cr = decl->type.cg = decl->type.cb = decl->type.ca = 1.0ulr;
463
+
452 464
    if(st->drop(tok_lt)) {
453 465
       G_etdcl *base =
454 466
          G_enttypes.find(st->expect(tok_identi, "base entity name")->textV);

+ 5
- 0
src/g_objdef.h View File

@@ -18,6 +18,10 @@
18 18
       (th).sx       = (type)->sx; \
19 19
       (th).sy       = (type)->sy; \
20 20
       (th).sz       = (type)->sz; \
21
+      (th).cr       = (type)->cr; \
22
+      (th).cg       = (type)->cg; \
23
+      (th).cb       = (type)->cb; \
24
+      (th).ca       = (type)->ca; \
21 25
       (th).subtype  = (type)->subtype; \
22 26
    } while(0)
23 27
 
@@ -53,6 +57,7 @@ typedef struct G_enttype
53 57
      fixed mass;
54 58
      fixed rsx, rsy;
55 59
      fixed sx, sy, sz;
60
+     ulfra cr, cg, cb, ca;
56 61
      mword subtype;
57 62
      mword ext;
58 63
    DGE_CallbackType task;

+ 3
- 0
src/g_player.c View File

@@ -59,6 +59,8 @@ void G_Player_Think(G_enttype const *ty, unsigned id)
59 59
    G_player   th   = {id};
60 60
    G_renderth shot = {DGE_RenderThinker_Create(0)};
61 61
 
62
+   G_Player_Count++;
63
+
62 64
    shot.rsx = 30;
63 65
    shot.rsy = 24;
64 66
 
@@ -73,6 +75,7 @@ void G_Player_Think(G_enttype const *ty, unsigned id)
73 75
    {
74 76
       G_Player_applyVelocity(ty, th);
75 77
 
78
+      // TODO: de-hardcode this
76 79
       if(G_Time < 70)
77 80
          th.y = th.y + log(G_Time / 70.0) * 0.7hk;
78 81
 

Loading…
Cancel
Save