Working GOL (No graphics

This commit is contained in:
Simon Robertshaw 2012-02-02 00:33:10 +00:00
parent f86091d421
commit f5dd32b284
8 changed files with 112 additions and 3 deletions

View File

@ -123,7 +123,7 @@ extern unsigned char ZSIZE;
#define SAVE_OPS
#define NGOL 25
#define NGOL 24
#define NGOLALT 24 //NGOL should be 24, but use this var until I find out why
#define CIRCLE_BRUSH 0

View File

@ -95,7 +95,7 @@ int graphics_LIFE(GRAPHICS_FUNC_ARGS)
else
pc = PIXRGB(255, 255, 0);
} else {
//pc = gmenu[cpart->ctype].colour;
pc = PIXRGB(255, 255, 0);//sim->gmenu[cpart->ctype].colour;
}
*colr = PIXR(pc);
*colg = PIXG(pc);

View File

@ -35,7 +35,11 @@ GameModel::GameModel():
}
//Build menu for GOL types
//for(int i = 0; i < GOL_)
for(int i = 0; i < NGOL; i++)
{
Tool * tempTool = new GolTool(i, sim->gmenu[i].name, PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour));
menuList[SC_LIFE]->AddTool(tempTool);
}
//Build other menus from wall data
for(int i = 0; i < UI_WALLCOUNT; i++)

View File

@ -53,4 +53,23 @@ public:
}
};
class GolTool: public Tool
{
public:
GolTool(int id, string name, int r, int g, int b):
Tool(id, name, r, g, b)
{
}
virtual ~GolTool() {}
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){
sim->create_parts(position.X, position.Y, 1, 1, PT_LIFE|(toolID<<8), 0, brush);
}
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
sim->create_line(position1.X, position1.Y, position2.X, position2.Y, 1, 1, PT_LIFE|(toolID<<8), 0, brush);
}
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
sim->create_box(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), 0);
}
};
#endif /* TOOL_H_ */

0
src/interface/Spinner Normal file
View File

View File

@ -3213,6 +3213,16 @@ Simulation::Simulation():
memcpy(ptransitions, ptransitionsT, sizeof(part_transition) * transitionCount);
free(ptransitionsT);
int golRulesCount;
int * golRulesT = LoadGOLRules(golRulesCount);
memcpy(grule, golRulesT, sizeof(int) * (golRulesCount*10));
free(golRulesT);
int golMenuCount;
gol_menu * golMenuT = LoadGOLMenu(golMenuCount);
memcpy(gmenu, golMenuT, sizeof(gol_menu) * golMenuCount);
free(golMenuT);
init_can_move();
clear_sim();
}

View File

@ -8,6 +8,78 @@
#include "ElementFunctions.h"
#include "ElementGraphics.h"
gol_menu * LoadGOLMenu(int & golMenuCount)
{
gol_menu golMenu[NGOL] =
{
{"GOL", PIXPACK(0x0CAC00), 0, "Game Of Life B3/S23"},
{"HLIF", PIXPACK(0xFF0000), 1, "High Life B36/S23"},
{"ASIM", PIXPACK(0x0000FF), 2, "Assimilation B345/S4567"},
{"2x2", PIXPACK(0xFFFF00), 3, "2x2 B36/S125"},
{"DANI", PIXPACK(0x00FFFF), 4, "Day and Night B3678/S34678"},
{"AMOE", PIXPACK(0xFF00FF), 5, "Amoeba B357/S1358"},
{"MOVE", PIXPACK(0xFFFFFF), 6, "'Move' particles. Does not move things.. it is a life type B368/S245"},
{"PGOL", PIXPACK(0xE05010), 7, "Pseudo Life B357/S238"},
{"DMOE", PIXPACK(0x500000), 8, "Diamoeba B35678/S5678"},
{"34", PIXPACK(0x500050), 9, "34 B34/S34"},
{"LLIF", PIXPACK(0x505050), 10, "Long Life B345/S5"},
{"STAN", PIXPACK(0x5000FF), 11, "Stains B3678/S235678"},
{"SEED", PIXPACK(0xFBEC7D), 12, "B2/S"},
{"MAZE", PIXPACK(0xA8E4A0), 13, "B3/S12345"},
{"COAG", PIXPACK(0x9ACD32), 14, "B378/S235678"},
{"WALL", PIXPACK(0x0047AB), 15, "B45678/S2345"},
{"GNAR", PIXPACK(0xE5B73B), 16, "B1/S1"},
{"REPL", PIXPACK(0x259588), 17, "B1357/S1357"},
{"MYST", PIXPACK(0x0C3C00), 18, "B3458/S05678"},
{"LOTE", PIXPACK(0xFF0000), 19, "Behaves kinda like Living on the Edge S3458/B37/4"},
{"FRG2", PIXPACK(0x00FF00), 20, "Like Frogs rule S124/B3/3"},
{"STAR", PIXPACK(0x0000FF), 21, "Like Star Wars rule S3456/B278/6"},
{"FROG", PIXPACK(0x00AA00), 22, "Frogs S12/B34/3"},
{"BRAN", PIXPACK(0xCCCC00), 23, "Brian 6 S6/B246/3"}
};
golMenuCount = NGOL;
gol_menu * golMenuT = (gol_menu*)malloc(NGOL*sizeof(gol_menu));
memcpy(golMenuT, golMenu, NGOL*sizeof(gol_menu));
return golMenuT;
}
int * LoadGOLRules(int & golRuleCount)
{
int golRules[NGOL+1][10] =
{
// 0,1,2,3,4,5,6,7,8,STATES live=1 spawn=2 spawn&live=3 States are kind of how long until it dies, normal ones use two states(living,dead) for others the intermediate states live but do nothing
{0,0,0,0,0,0,0,0,0,2},//blank
{0,0,1,3,0,0,0,0,0,2},//GOL
{0,0,1,3,0,0,2,0,0,2},//HLIF
{0,0,0,2,3,3,1,1,0,2},//ASIM
{0,1,1,2,0,1,2,0,0,2},//2x2
{0,0,0,3,1,0,3,3,3,2},//DANI
{0,1,0,3,0,3,0,2,1,2},//AMOE
{0,0,1,2,1,1,2,0,2,2},//MOVE
{0,0,1,3,0,2,0,2,1,2},//PGOL
{0,0,0,2,0,3,3,3,3,2},//DMOE
{0,0,0,3,3,0,0,0,0,2},//34
{0,0,0,2,2,3,0,0,0,2},//LLIF
{0,0,1,3,0,1,3,3,3,2},//STAN
{0,0,2,0,0,0,0,0,0,2},//SEED
{0,1,1,3,1,1,0,0,0,2},//MAZE
{0,0,1,3,0,1,1,3,3,2},//COAG
{0,0,1,1,3,3,2,2,2,2},//WALL
{0,3,0,0,0,0,0,0,0,2},//GNAR
{0,3,0,3,0,3,0,3,0,2},//REPL
{1,0,0,2,2,3,1,1,3,2},//MYST
{0,0,0,3,1,1,0,2,1,4},//LOTE
{0,1,1,2,1,0,0,0,0,3},//FRG2
{0,0,2,1,1,1,1,2,2,6},//STAR
{0,1,1,2,2,0,0,0,0,3},//FROG
{0,0,2,0,2,0,3,0,0,3},//BRAN
};
golRuleCount = NGOL+1;
int * golRulesT = (int*)malloc((golRuleCount*10)*sizeof(int));
memcpy(golRulesT, golRules, (golRuleCount*10)*sizeof(int));
return golRulesT;
}
wall_type * LoadWalls(int & wallCount)
{
wall_type wtypes[] =

View File

@ -75,6 +75,10 @@ struct menu_section;
struct wall_type;
gol_menu * LoadGOLMenu(int & golMenuCount);
int * LoadGOLRules(int & golRuleCount);
wall_type * LoadWalls(int & wallCount);
menu_section * LoadMenus(int & menuCount);