ultimatepp/uppdev/Gen2/Gen2.h
cxl 3cd394812c Merge continued
git-svn-id: svn://ultimatepp.org/upp/trunk@10263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-10-04 08:34:39 +00:00

69 lines
1.1 KiB
C++

#ifndef _Gen2_Gen2_h_
#define _Gen2_Gen2_h_
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
enum {
EMPTY, HARDTRAP = 30, TRAP = 60, ROCK = 100, GRASS = 150,
};
enum {
PMSK = 1023,
WSZ = PMSK + 1
};
struct Creature;
struct World : public TopWindow {
struct Spot {
byte kind;
byte energy;
Creature *creature;
};
Spot (*spot)[WSZ];
int step;
Array<Creature> creature;
int born, died;
virtual void Paint(Draw& w);
void Step();
void Die(int i, const char *cause);
typedef World CLASSNAME;
World();
~World();
};
struct Gen {
byte op;
word op1;
word op2;
int value;
};
struct Creature {
Color color;
Gen gen[8192];
int energy;
int collected;
int generation;
Point pos;
Point ppos;
int Op1(const Gen& g) { return gen[g.op1 & 8191].value; }
int Op2(const Gen& g) { return gen[g.op2 & 8191].value; }
void Step();
void Random();
Creature() { collected = 0; generation = 0; }
};
#endif