diff -Naur ttn/Makefile ttn-0.3-gentoo/Makefile --- ttn/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ ttn-0.3-gentoo/Makefile 2007-07-14 23:27:22.000000000 +0200 @@ -0,0 +1,30 @@ +DC=gdmd +#DC=gdc +ifeq ($(DC), gdmd) +DFLAGS=-O -release -Iimport -Isrc +#DFLAGS=-g -debug -Iimport -Isrc +DOUT=-of +else +DFLAGS=-O -frelease -Iimport -Isrc +#DFLAGS=-g -fdebug -Iimport -Isrc +DOUT=-o +endif + +DSRC=$(shell find src/abagames -name "*.d") +SOURCES=$(DSRC) import/SDL_video.d import/SDL_mixer.d +OBJS=$(SOURCES:.d=.o) +EXE=titanion + +all: $(EXE) + +$(EXE): $(OBJS) + gcc -o $@ $(OBJS) -lgphobos -lpthread -lm -lSDL -lGL -lGLU -lSDL_mixer + +$(OBJS): + $(DC) -c -op $(DFLAGS) $(SOURCES) + +#$(OBJS): %.o: %.d +# $(DC) -c $(DOUT)$@ $(DFLAGS) $< + +clean: + rm -f $(OBJS) $(EXE) diff -Naur ttn/src/abagames/ttn/bullet.d ttn-0.3-gentoo/src/abagames/ttn/bullet.d --- ttn/src/abagames/ttn/bullet.d 2006-12-04 17:04:26.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/ttn/bullet.d 2006-12-20 11:11:30.000000000 +0100 @@ -59,7 +59,54 @@ } } -public class Bullet: Token!(BulletState, BulletSpec) { +public class Token2(ST, SP): Actor { + protected: + ST state; + SP spec; + + public void init(Object[] args) { + state = new ST; + } + + public void set(SP spec, Vector pos, float deg, float speed) { + set(spec, pos.x, pos.y, deg, speed); + } + + public void set(SP spec, float x, float y, float deg, float speed) { + this.spec = spec; + set(x, y, deg, speed); + } + + public void set(float x, float y, float deg, float speed) { + state.clear(); + state.pos.x = x; + state.pos.y = y; + state.deg = deg; + state.speed = speed; + spec.set(state); + _exists = true; + } + + public void move() { + if (!spec.move(state)) + remove(); + } + + public void remove() { + _exists = false; + spec.removed(state); + } + + public void draw() { + spec.draw(state); + } + + public Vector pos() { + return state.pos; + } +} + +public class Bullet: Token2!(BulletState, BulletSpec) { private: public void setWaitCnt(int c) { @@ -102,7 +149,28 @@ } } -public class BulletSpec: TokenSpec!(BulletState) { +public class TokenSpec2(T) { + protected: + Field field; + Shape shape; + + public void set(T state) {} + public void removed(T state) {} + + public bool move(T state) { + return true; + } + + public void draw(T state) { + with (state) { + Vector3 p = field.calcCircularPos(pos); + float cd = field.calcCircularDeg(pos.x); + shape.draw(p, cd, deg); + } + } +} + +public class BulletSpec: TokenSpec2!(BulletState) { private: static const float DISAPPEAR_CNT = 300; Player player; diff -Naur ttn/src/abagames/ttn/enemy.d ttn-0.3-gentoo/src/abagames/ttn/enemy.d --- ttn/src/abagames/ttn/enemy.d 2006-12-09 05:17:40.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/ttn/enemy.d 2006-12-20 11:08:43.000000000 +0100 @@ -188,7 +188,54 @@ } } -public class Enemy: Token!(EnemyState, EnemySpec) { +public class Token2(ST, SP): Actor { + protected: + ST state; + SP spec; + + public void init(Object[] args) { + state = new ST; + } + + public void set(SP spec, Vector pos, float deg, float speed) { + set(spec, pos.x, pos.y, deg, speed); + } + + public void set(SP spec, float x, float y, float deg, float speed) { + this.spec = spec; + set(x, y, deg, speed); + } + + public void set(float x, float y, float deg, float speed) { + state.clear(); + state.pos.x = x; + state.pos.y = y; + state.deg = deg; + state.speed = speed; + spec.set(state); + _exists = true; + } + + public void move() { + if (!spec.move(state)) + remove(); + } + + public void remove() { + _exists = false; + spec.removed(state); + } + + public void draw() { + spec.draw(state); + } + + public Vector pos() { + return state.pos; + } +} + +public class Enemy: Token2!(EnemyState, EnemySpec) { private: public override void init(Object[] args) { @@ -423,7 +470,28 @@ } } -public class EnemySpec: TokenSpec!(EnemyState) { +public class TokenSpec2(T) { + protected: + Field field; + Shape shape; + + public void set(T state) {} + public void removed(T state) {} + + public bool move(T state) { + return true; + } + + public void draw(T state) { + with (state) { + Vector3 p = field.calcCircularPos(pos); + float cd = field.calcCircularDeg(pos.x); + shape.draw(p, cd, deg); + } + } +} + +public class EnemySpec: TokenSpec2!(EnemyState) { mixin StaticRandImpl; protected: static const float BULLET_HIT_WIDTH = 0.8f; @@ -1464,7 +1532,7 @@ } } -public class TurretSpec: TokenSpec!(TurretState) { +public class TurretSpec: TokenSpec2!(TurretState) { mixin StaticRandImpl; public: static const float SPEED_RATIO = 5.0f; diff -Naur ttn/src/abagames/ttn/particle.d ttn-0.3-gentoo/src/abagames/ttn/particle.d --- ttn/src/abagames/ttn/particle.d 2006-12-04 17:04:26.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/ttn/particle.d 2006-12-20 11:04:34.000000000 +0100 @@ -24,7 +24,55 @@ public class ParticlePool: ActorPool!(Particle) { } -public class Particle: Token!(ParticleState, ParticleSpec) { +public class Token2(ST, SP): Actor { + protected: + ST state; + SP spec; + + public void init(Object[] args) { + state = new ST; + } + + public void set(SP spec, Vector pos, float deg, float speed) { + set(spec, pos.x, pos.y, deg, speed); + } + + public void set(SP spec, float x, float y, float deg, float speed) { + this.spec = spec; + set(x, y, deg, speed); + } + + public void set(float x, float y, float deg, float speed) { + state.clear(); + state.pos.x = x; + state.pos.y = y; + state.deg = deg; + state.speed = speed; + spec.set(state); + _exists = true; + } + + public void move() { + if (!spec.move(state)) + remove(); + } + + public void remove() { + _exists = false; + spec.removed(state); + } + + public void draw() { + spec.draw(state); + } + + public Vector pos() { + return state.pos; + } +} + + +public class Particle: Token2!(ParticleState, ParticleSpec) { public: static const enum Shape { TRIANGLE, LINE, QUAD, BONUS, @@ -153,7 +201,28 @@ } } -public class ParticleSpec: TokenSpec!(ParticleState) { +public class TokenSpec2(T) { + protected: + Field field; + Shape shape; + + public void set(T state) {} + public void removed(T state) {} + + public bool move(T state) { + return true; + } + + public void draw(T state) { + with (state) { + Vector3 p = field.calcCircularPos(pos); + float cd = field.calcCircularDeg(pos.x); + shape.draw(p, cd, deg); + } + } +} + +public class ParticleSpec: TokenSpec2!(ParticleState) { mixin StaticRandImpl; private: Player player; diff -Naur ttn/src/abagames/ttn/pillar.d ttn-0.3-gentoo/src/abagames/ttn/pillar.d --- ttn/src/abagames/ttn/pillar.d 2006-11-19 08:54:55.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/ttn/pillar.d 2006-12-20 11:06:53.000000000 +0100 @@ -6,6 +6,7 @@ module abagames.ttn.pillar; private import std.math; +private import abagames.util.vector; private import abagames.util.actor; private import abagames.ttn.field; private import abagames.ttn.token; @@ -38,7 +39,54 @@ } } -public class Pillar: Token!(PillarState, PillarSpec) { +public class Token2(ST, SP): Actor { + protected: + ST state; + SP spec; + + public void init(Object[] args) { + state = new ST; + } + + public void set(SP spec, Vector pos, float deg, float speed) { + set(spec, pos.x, pos.y, deg, speed); + } + + public void set(SP spec, float x, float y, float deg, float speed) { + this.spec = spec; + set(x, y, deg, speed); + } + + public void set(float x, float y, float deg, float speed) { + state.clear(); + state.pos.x = x; + state.pos.y = y; + state.deg = deg; + state.speed = speed; + spec.set(state); + _exists = true; + } + + public void move() { + if (!spec.move(state)) + remove(); + } + + public void remove() { + _exists = false; + spec.removed(state); + } + + public void draw() { + spec.draw(state); + } + + public Vector pos() { + return state.pos; + } +} + +public class Pillar: Token2!(PillarState, PillarSpec) { private: public void set(PillarSpec ps, float y, float maxY, Pillar pp, PillarShape s, float vdeg, bool outside = false) { @@ -83,7 +131,28 @@ } } -public class PillarSpec:TokenSpec!(PillarState) { +public class TokenSpec2(T) { + protected: + Field field; + Shape shape; + + public void set(T state) {} + public void removed(T state) {} + + public bool move(T state) { + return true; + } + + public void draw(T state) { + with (state) { + Vector3 p = field.calcCircularPos(pos); + float cd = field.calcCircularDeg(pos.x); + shape.draw(p, cd, deg); + } + } +} + +public class PillarSpec:TokenSpec2!(PillarState) { private: static const VELOCITY_Y = 0.025f; diff -Naur ttn/src/abagames/ttn/player.d ttn-0.3-gentoo/src/abagames/ttn/player.d --- ttn/src/abagames/ttn/player.d 2006-12-04 17:04:26.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/ttn/player.d 2006-12-20 11:10:19.000000000 +0100 @@ -24,10 +24,57 @@ private import abagames.ttn.sound; private import abagames.ttn.letter; +public class Token2(ST, SP): Actor { + protected: + ST state; + SP spec; + + public void init(Object[] args) { + state = new ST; + } + + public void set(SP spec, Vector pos, float deg, float speed) { + set(spec, pos.x, pos.y, deg, speed); + } + + public void set(SP spec, float x, float y, float deg, float speed) { + this.spec = spec; + set(x, y, deg, speed); + } + + public void set(float x, float y, float deg, float speed) { + state.clear(); + state.pos.x = x; + state.pos.y = y; + state.deg = deg; + state.speed = speed; + spec.set(state); + _exists = true; + } + + public void move() { + if (!spec.move(state)) + remove(); + } + + public void remove() { + _exists = false; + spec.removed(state); + } + + public void draw() { + spec.draw(state); + } + + public Vector pos() { + return state.pos; + } +} + /** * Player and shots. */ -public class Player: Token!(PlayerState, PlayerSpec) { +public class Player: Token2!(PlayerState, PlayerSpec) { private: Vector hitOffset; @@ -300,7 +347,28 @@ } } -public class PlayerSpec: TokenSpec!(PlayerState) { +public class TokenSpec2(T) { + protected: + Field field; + Shape shape; + + public void set(T state) {} + public void removed(T state) {} + + public bool move(T state) { + return true; + } + + public void draw(T state) { + with (state) { + Vector3 p = field.calcCircularPos(pos); + float cd = field.calcCircularDeg(pos.x); + shape.draw(p, cd, deg); + } + } +} + +public class PlayerSpec: TokenSpec2!(PlayerState) { mixin StaticRandImpl; public: static const float BASE_SPEED = 0.15f; @@ -768,7 +836,7 @@ } } -public class Shot: Token!(ShotState, ShotSpec) { +public class Shot: Token2!(ShotState, ShotSpec) { private: public void setParent(Shot s) { @@ -788,7 +856,7 @@ } } -public class ShotSpec: TokenSpec!(ShotState) { +public class ShotSpec: TokenSpec2!(ShotState) { private: EnemyPool enemies; BulletPool bullets; diff -Naur ttn/src/abagames/ttn/screen.d ttn-0.3-gentoo/src/abagames/ttn/screen.d --- ttn/src/abagames/ttn/screen.d 2006-12-04 17:04:26.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/ttn/screen.d 2006-12-20 11:13:01.000000000 +0100 @@ -21,7 +21,7 @@ Field field; protected void setIcon() { - SDL_WM_SetIcon(SDL_LoadBMP(ICON_FILE_NAME), null); +// SDL_WM_SetIcon(SDL_LoadBMP(ICON_FILE_NAME), null); } protected void init() { diff -Naur ttn/src/abagames/util/rand.d ttn-0.3-gentoo/src/abagames/util/rand.d --- ttn/src/abagames/util/rand.d 2006-11-19 08:54:55.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/util/rand.d 2007-07-14 13:58:30.000000000 +0200 @@ -176,14 +176,14 @@ void next_state() { - uint *p=state; + uint *p=state.ptr; /* if init_genrand() has not been called, */ /* a default initial seed is used */ if (initf==0) init_genrand(5489UL); left = N; - next = state; + next = state.ptr; for (int j=N-M+1; --j; p++) *p = p[M] ^ TWIST(p[0], p[1]); diff -Naur ttn/src/abagames/util/sdl/texture.d ttn-0.3-gentoo/src/abagames/util/sdl/texture.d --- ttn/src/abagames/util/sdl/texture.d 2006-11-19 08:54:55.000000000 +0100 +++ ttn-0.3-gentoo/src/abagames/util/sdl/texture.d 2007-07-14 23:25:47.000000000 +0200 @@ -103,13 +103,13 @@ } glBindTexture(GL_TEXTURE_2D, num + ti); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight, - GL_RGBA, GL_UNSIGNED_BYTE, pixels); + GL_RGBA, GL_UNSIGNED_BYTE, pixels.ptr); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); if (maskColor != 0xffffffffu) { glBindTexture(GL_TEXTURE_2D, maskNum + ti); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight, - GL_RGBA, GL_UNSIGNED_BYTE, maskPixels); + GL_RGBA, GL_UNSIGNED_BYTE, maskPixels.ptr); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); }