Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 185582 | Differences between
and this patch

Collapse All | Expand All

(-)ttn/Makefile (+30 lines)
Line 0 Link Here
1
DC=gdmd
2
#DC=gdc
3
ifeq ($(DC), gdmd)
4
DFLAGS=-O -release -Iimport -Isrc
5
#DFLAGS=-g -debug -Iimport -Isrc
6
DOUT=-of
7
else
8
DFLAGS=-O -frelease -Iimport -Isrc
9
#DFLAGS=-g -fdebug -Iimport -Isrc
10
DOUT=-o
11
endif
12
13
DSRC=$(shell find src/abagames -name "*.d")
14
SOURCES=$(DSRC) import/SDL_video.d import/SDL_mixer.d
15
OBJS=$(SOURCES:.d=.o)
16
EXE=titanion
17
18
all: $(EXE)
19
20
$(EXE): $(OBJS)
21
	gcc -o $@ $(OBJS) -lgphobos -lpthread -lm -lSDL -lGL -lGLU -lSDL_mixer
22
23
$(OBJS):
24
	$(DC) -c -op $(DFLAGS) $(SOURCES)
25
26
#$(OBJS): %.o: %.d
27
#	$(DC) -c $(DOUT)$@ $(DFLAGS) $<
28
29
clean:
30
	rm -f $(OBJS) $(EXE)
(-)ttn/src/abagames/ttn/bullet.d (-2 / +70 lines)
Lines 59-65 Link Here
59
  }
59
  }
60
}
60
}
61
61
62
public class Bullet: Token!(BulletState, BulletSpec) {
62
public class Token2(ST, SP): Actor {
63
 protected:
64
  ST state;
65
  SP spec;
66
67
  public void init(Object[] args) {
68
    state = new ST;
69
  }
70
71
  public void set(SP spec, Vector pos, float deg, float speed) {
72
    set(spec, pos.x, pos.y, deg, speed);
73
  }
74
75
  public void set(SP spec, float x, float y, float deg, float speed) {
76
    this.spec = spec;
77
    set(x, y, deg, speed);
78
  }
79
80
  public void set(float x, float y, float deg, float speed) {
81
    state.clear();
82
    state.pos.x = x;
83
    state.pos.y = y;
84
    state.deg = deg;
85
    state.speed = speed;
86
    spec.set(state);
87
    _exists = true;
88
  }
89
90
  public void move() {
91
    if (!spec.move(state))
92
      remove();
93
  }
94
95
  public void remove() {
96
    _exists = false;
97
    spec.removed(state);
98
  }
99
100
  public void draw() {
101
    spec.draw(state);
102
  }
103
104
  public Vector pos() {
105
    return state.pos;
106
  }
107
}
108
109
public class Bullet: Token2!(BulletState, BulletSpec) {
63
 private:
110
 private:
64
111
65
  public void setWaitCnt(int c) {
112
  public void setWaitCnt(int c) {
Lines 102-108 Link Here
102
  }
149
  }
103
}
150
}
104
151
105
public class BulletSpec: TokenSpec!(BulletState) {
152
public class TokenSpec2(T) {
153
 protected:
154
  Field field;
155
  Shape shape;
156
157
  public void set(T state) {}
158
  public void removed(T state) {}
159
160
  public bool move(T state) {
161
    return true;
162
  }
163
164
  public void draw(T state) {
165
    with (state) {
166
      Vector3 p = field.calcCircularPos(pos);
167
      float cd = field.calcCircularDeg(pos.x);
168
      shape.draw(p, cd, deg);
169
    }
170
  }
171
}
172
173
public class BulletSpec: TokenSpec2!(BulletState) {
106
 private:
174
 private:
107
  static const float DISAPPEAR_CNT = 300;
175
  static const float DISAPPEAR_CNT = 300;
108
  Player player;
176
  Player player;
(-)ttn/src/abagames/ttn/enemy.d (-3 / +71 lines)
Lines 188-194 Link Here
188
  }
188
  }
189
}
189
}
190
190
191
public class Enemy: Token!(EnemyState, EnemySpec) {
191
public class Token2(ST, SP): Actor {
192
 protected:
193
  ST state;
194
  SP spec;
195
196
  public void init(Object[] args) {
197
    state = new ST;
198
  }
199
200
  public void set(SP spec, Vector pos, float deg, float speed) {
201
    set(spec, pos.x, pos.y, deg, speed);
202
  }
203
204
  public void set(SP spec, float x, float y, float deg, float speed) {
205
    this.spec = spec;
206
    set(x, y, deg, speed);
207
  }
208
209
  public void set(float x, float y, float deg, float speed) {
210
    state.clear();
211
    state.pos.x = x;
212
    state.pos.y = y;
213
    state.deg = deg;
214
    state.speed = speed;
215
    spec.set(state);
216
    _exists = true;
217
  }
218
219
  public void move() {
220
    if (!spec.move(state))
221
      remove();
222
  }
223
224
  public void remove() {
225
    _exists = false;
226
    spec.removed(state);
227
  }
228
229
  public void draw() {
230
    spec.draw(state);
231
  }
232
233
  public Vector pos() {
234
    return state.pos;
235
  }
236
}
237
238
public class Enemy: Token2!(EnemyState, EnemySpec) {
192
 private:
239
 private:
193
240
194
  public override void init(Object[] args) {
241
  public override void init(Object[] args) {
Lines 423-429 Link Here
423
  }
470
  }
424
}
471
}
425
472
426
public class EnemySpec: TokenSpec!(EnemyState) {
473
public class TokenSpec2(T) {
474
 protected:
475
  Field field;
476
  Shape shape;
477
478
  public void set(T state) {}
479
  public void removed(T state) {}
480
481
  public bool move(T state) {
482
    return true;
483
  }
484
485
  public void draw(T state) {
486
    with (state) {
487
      Vector3 p = field.calcCircularPos(pos);
488
      float cd = field.calcCircularDeg(pos.x);
489
      shape.draw(p, cd, deg);
490
    }
491
  }
492
}
493
494
public class EnemySpec: TokenSpec2!(EnemyState) {
427
  mixin StaticRandImpl;
495
  mixin StaticRandImpl;
428
 protected:
496
 protected:
429
  static const float BULLET_HIT_WIDTH = 0.8f;
497
  static const float BULLET_HIT_WIDTH = 0.8f;
Lines 1464-1470 Link Here
1464
  }
1532
  }
1465
}
1533
}
1466
1534
1467
public class TurretSpec: TokenSpec!(TurretState) {
1535
public class TurretSpec: TokenSpec2!(TurretState) {
1468
  mixin StaticRandImpl;
1536
  mixin StaticRandImpl;
1469
 public:
1537
 public:
1470
  static const float SPEED_RATIO = 5.0f;
1538
  static const float SPEED_RATIO = 5.0f;
(-)ttn/src/abagames/ttn/particle.d (-2 / +71 lines)
Lines 24-30 Link Here
24
public class ParticlePool: ActorPool!(Particle) {
24
public class ParticlePool: ActorPool!(Particle) {
25
}
25
}
26
26
27
public class Particle: Token!(ParticleState, ParticleSpec) {
27
public class Token2(ST, SP): Actor {
28
 protected:
29
  ST state;
30
  SP spec;
31
32
  public void init(Object[] args) {
33
    state = new ST;
34
  }
35
36
  public void set(SP spec, Vector pos, float deg, float speed) {
37
    set(spec, pos.x, pos.y, deg, speed);
38
  }
39
40
  public void set(SP spec, float x, float y, float deg, float speed) {
41
    this.spec = spec;
42
    set(x, y, deg, speed);
43
  }
44
45
  public void set(float x, float y, float deg, float speed) {
46
    state.clear();
47
    state.pos.x = x;
48
    state.pos.y = y;
49
    state.deg = deg;
50
    state.speed = speed;
51
    spec.set(state);
52
    _exists = true;
53
  }
54
55
  public void move() {
56
    if (!spec.move(state))
57
      remove();
58
  }
59
60
  public void remove() {
61
    _exists = false;
62
    spec.removed(state);
63
  }
64
65
  public void draw() {
66
    spec.draw(state);
67
  }
68
69
  public Vector pos() {
70
    return state.pos;
71
  }
72
}
73
74
75
public class Particle: Token2!(ParticleState, ParticleSpec) {
28
 public:
76
 public:
29
  static const enum Shape {
77
  static const enum Shape {
30
    TRIANGLE, LINE, QUAD, BONUS,
78
    TRIANGLE, LINE, QUAD, BONUS,
Lines 153-159 Link Here
153
  }
201
  }
154
}
202
}
155
203
156
public class ParticleSpec: TokenSpec!(ParticleState) {
204
public class TokenSpec2(T) {
205
 protected:
206
  Field field;
207
  Shape shape;
208
209
  public void set(T state) {}
210
  public void removed(T state) {}
211
212
  public bool move(T state) {
213
    return true;
214
  }
215
216
  public void draw(T state) {
217
    with (state) {
218
      Vector3 p = field.calcCircularPos(pos);
219
      float cd = field.calcCircularDeg(pos.x);
220
      shape.draw(p, cd, deg);
221
    }
222
  }
223
}
224
225
public class ParticleSpec: TokenSpec2!(ParticleState) {
157
  mixin StaticRandImpl;
226
  mixin StaticRandImpl;
158
 private:
227
 private:
159
  Player player;
228
  Player player;
(-)ttn/src/abagames/ttn/pillar.d (-2 / +71 lines)
Lines 6-11 Link Here
6
module abagames.ttn.pillar;
6
module abagames.ttn.pillar;
7
7
8
private import std.math;
8
private import std.math;
9
private import abagames.util.vector;
9
private import abagames.util.actor;
10
private import abagames.util.actor;
10
private import abagames.ttn.field;
11
private import abagames.ttn.field;
11
private import abagames.ttn.token;
12
private import abagames.ttn.token;
Lines 38-44 Link Here
38
  }
39
  }
39
}
40
}
40
41
41
public class Pillar: Token!(PillarState, PillarSpec) {
42
public class Token2(ST, SP): Actor {
43
 protected:
44
  ST state;
45
  SP spec;
46
47
  public void init(Object[] args) {
48
    state = new ST;
49
  }
50
51
  public void set(SP spec, Vector pos, float deg, float speed) {
52
    set(spec, pos.x, pos.y, deg, speed);
53
  }
54
55
  public void set(SP spec, float x, float y, float deg, float speed) {
56
    this.spec = spec;
57
    set(x, y, deg, speed);
58
  }
59
60
  public void set(float x, float y, float deg, float speed) {
61
    state.clear();
62
    state.pos.x = x;
63
    state.pos.y = y;
64
    state.deg = deg;
65
    state.speed = speed;
66
    spec.set(state);
67
    _exists = true;
68
  }
69
70
  public void move() {
71
    if (!spec.move(state))
72
      remove();
73
  }
74
75
  public void remove() {
76
    _exists = false;
77
    spec.removed(state);
78
  }
79
80
  public void draw() {
81
    spec.draw(state);
82
  }
83
84
  public Vector pos() {
85
    return state.pos;
86
  }
87
}
88
89
public class Pillar: Token2!(PillarState, PillarSpec) {
42
 private:
90
 private:
43
91
44
  public void set(PillarSpec ps, float y, float maxY, Pillar pp, PillarShape s, float vdeg, bool outside = false) {
92
  public void set(PillarSpec ps, float y, float maxY, Pillar pp, PillarShape s, float vdeg, bool outside = false) {
Lines 83-89 Link Here
83
  }
131
  }
84
}
132
}
85
133
86
public class PillarSpec:TokenSpec!(PillarState) {
134
public class TokenSpec2(T) {
135
 protected:
136
  Field field;
137
  Shape shape;
138
139
  public void set(T state) {}
140
  public void removed(T state) {}
141
142
  public bool move(T state) {
143
    return true;
144
  }
145
146
  public void draw(T state) {
147
    with (state) {
148
      Vector3 p = field.calcCircularPos(pos);
149
      float cd = field.calcCircularDeg(pos.x);
150
      shape.draw(p, cd, deg);
151
    }
152
  }
153
}
154
155
public class PillarSpec:TokenSpec2!(PillarState) {
87
 private:
156
 private:
88
  static const VELOCITY_Y = 0.025f;
157
  static const VELOCITY_Y = 0.025f;
89
158
(-)ttn/src/abagames/ttn/player.d (-4 / +72 lines)
Lines 24-33 Link Here
24
private import abagames.ttn.sound;
24
private import abagames.ttn.sound;
25
private import abagames.ttn.letter;
25
private import abagames.ttn.letter;
26
26
27
public class Token2(ST, SP): Actor {
28
 protected:
29
  ST state;
30
  SP spec;
31
32
  public void init(Object[] args) {
33
    state = new ST;
34
  }
35
36
  public void set(SP spec, Vector pos, float deg, float speed) {
37
    set(spec, pos.x, pos.y, deg, speed);
38
  }
39
40
  public void set(SP spec, float x, float y, float deg, float speed) {
41
    this.spec = spec;
42
    set(x, y, deg, speed);
43
  }
44
45
  public void set(float x, float y, float deg, float speed) {
46
    state.clear();
47
    state.pos.x = x;
48
    state.pos.y = y;
49
    state.deg = deg;
50
    state.speed = speed;
51
    spec.set(state);
52
    _exists = true;
53
  }
54
55
  public void move() {
56
    if (!spec.move(state))
57
      remove();
58
  }
59
60
  public void remove() {
61
    _exists = false;
62
    spec.removed(state);
63
  }
64
65
  public void draw() {
66
    spec.draw(state);
67
  }
68
69
  public Vector pos() {
70
    return state.pos;
71
  }
72
}
73
27
/**
74
/**
28
 * Player and shots.
75
 * Player and shots.
29
 */
76
 */
30
public class Player: Token!(PlayerState, PlayerSpec) {
77
public class Player: Token2!(PlayerState, PlayerSpec) {
31
 private:
78
 private:
32
  Vector hitOffset;
79
  Vector hitOffset;
33
80
Lines 300-306 Link Here
300
  }
347
  }
301
}
348
}
302
349
303
public class PlayerSpec: TokenSpec!(PlayerState) {
350
public class TokenSpec2(T) {
351
 protected:
352
  Field field;
353
  Shape shape;
354
355
  public void set(T state) {}
356
  public void removed(T state) {}
357
358
  public bool move(T state) {
359
    return true;
360
  }
361
362
  public void draw(T state) {
363
    with (state) {
364
      Vector3 p = field.calcCircularPos(pos);
365
      float cd = field.calcCircularDeg(pos.x);
366
      shape.draw(p, cd, deg);
367
    }
368
  }
369
}
370
371
public class PlayerSpec: TokenSpec2!(PlayerState) {
304
  mixin StaticRandImpl;
372
  mixin StaticRandImpl;
305
 public:
373
 public:
306
  static const float BASE_SPEED = 0.15f;
374
  static const float BASE_SPEED = 0.15f;
Lines 768-774 Link Here
768
  }
836
  }
769
}
837
}
770
838
771
public class Shot: Token!(ShotState, ShotSpec) {
839
public class Shot: Token2!(ShotState, ShotSpec) {
772
 private:
840
 private:
773
  
841
  
774
  public void setParent(Shot s) {
842
  public void setParent(Shot s) {
Lines 788-794 Link Here
788
  }
856
  }
789
}
857
}
790
858
791
public class ShotSpec: TokenSpec!(ShotState) {
859
public class ShotSpec: TokenSpec2!(ShotState) {
792
 private:
860
 private:
793
  EnemyPool enemies;
861
  EnemyPool enemies;
794
  BulletPool bullets;
862
  BulletPool bullets;
(-)ttn/src/abagames/ttn/screen.d (-1 / +1 lines)
Lines 21-27 Link Here
21
  Field field;
21
  Field field;
22
22
23
  protected void setIcon() {
23
  protected void setIcon() {
24
    SDL_WM_SetIcon(SDL_LoadBMP(ICON_FILE_NAME), null);
24
//    SDL_WM_SetIcon(SDL_LoadBMP(ICON_FILE_NAME), null);
25
  }
25
  }
26
26
27
  protected void init() {
27
  protected void init() {
(-)ttn/src/abagames/util/rand.d (-2 / +2 lines)
Lines 176-189 Link Here
176
176
177
void next_state()
177
void next_state()
178
{
178
{
179
    uint *p=state;
179
    uint *p=state.ptr;
180
180
181
    /* if init_genrand() has not been called, */
181
    /* if init_genrand() has not been called, */
182
    /* a default initial seed is used         */
182
    /* a default initial seed is used         */
183
    if (initf==0) init_genrand(5489UL);
183
    if (initf==0) init_genrand(5489UL);
184
184
185
    left = N;
185
    left = N;
186
    next = state;
186
    next = state.ptr;
187
    
187
    
188
    for (int j=N-M+1; --j; p++) 
188
    for (int j=N-M+1; --j; p++) 
189
        *p = p[M] ^ TWIST(p[0], p[1]);
189
        *p = p[M] ^ TWIST(p[0], p[1]);
(-)ttn/src/abagames/util/sdl/texture.d (-2 / +2 lines)
Lines 103-115 Link Here
103
        }
103
        }
104
        glBindTexture(GL_TEXTURE_2D, num + ti);
104
        glBindTexture(GL_TEXTURE_2D, num + ti);
105
        gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight,
105
        gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight,
106
                          GL_RGBA, GL_UNSIGNED_BYTE, pixels);
106
                          GL_RGBA, GL_UNSIGNED_BYTE, pixels.ptr);
107
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
107
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
108
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
108
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
109
        if (maskColor != 0xffffffffu) {
109
        if (maskColor != 0xffffffffu) {
110
          glBindTexture(GL_TEXTURE_2D, maskNum + ti);
110
          glBindTexture(GL_TEXTURE_2D, maskNum + ti);
111
          gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight,
111
          gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight,
112
                            GL_RGBA, GL_UNSIGNED_BYTE, maskPixels);
112
                            GL_RGBA, GL_UNSIGNED_BYTE, maskPixels.ptr);
113
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
113
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
114
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
114
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
115
        }
115
        }

Return to bug 185582