[xiph-commits] r10068 - trunk/planarity

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sun Sep 25 22:31:58 PDT 2005


Author: xiphmont
Date: 2005-09-25 22:31:56 -0700 (Sun, 25 Sep 2005)
New Revision: 10068

Added:
   trunk/planarity/graph_generate_data.c
Modified:
   trunk/planarity/Makefile
   trunk/planarity/graph_generate.c
   trunk/planarity/graph_generate.h
   trunk/planarity/version.h
Log:
Add interface to build levels out of raw information
Add first manufactured level



Modified: trunk/planarity/Makefile
===================================================================
--- trunk/planarity/Makefile	2005-09-26 03:44:51 UTC (rev 10067)
+++ trunk/planarity/Makefile	2005-09-26 05:31:56 UTC (rev 10068)
@@ -24,7 +24,7 @@
 	gameboard_draw_intersection.c graph_generate_mesh1.c gameboard_draw_main.c\
 	gameboard_draw_score.c main.c gameboard_draw_selection.c\
 	timer.c gameboard_draw_vertex.c levelstate.c dialog_level.c\
-	dialog_level_icons.c gameboard_draw_text.c random.c
+	dialog_level_icons.c gameboard_draw_text.c random.c graph_generate_data.c
 OBJ  = dialog_finish.o gameboard_logic.o dialog_pause.o gameboard_logic_button.o\
 	gameboard.o gameboard_logic_buttonbar.o gameboard_draw_box.o\
 	gameboard_logic_mouse.o gameboard_draw_button.o gameboard_logic_push.o\
@@ -33,7 +33,7 @@
 	gameboard_draw_intersection.o graph_generate_mesh1.o gameboard_draw_main.o\
 	gameboard_draw_score.o main.o gameboard_draw_selection.o\
 	timer.o gameboard_draw_vertex.o levelstate.o dialog_level.o\
-	dialog_level_icons.o gameboard_draw_text.o random.o
+	dialog_level_icons.o gameboard_draw_text.o random.o graph_generate_data.o
 GCF  = `pkg-config --static --cflags "gtk+-2.0 >= 2.7.2"`
 
 # uncomment below for a normal dynamic build

Modified: trunk/planarity/graph_generate.c
===================================================================
--- trunk/planarity/graph_generate.c	2005-09-26 03:44:51 UTC (rev 10067)
+++ trunk/planarity/graph_generate.c	2005-09-26 05:31:56 UTC (rev 10068)
@@ -40,14 +40,17 @@
   int unlock;
 } gen_instance;
 
-#define FINITE_LEVELS 1
+#define FINITE_LEVELS 3
 static gen_instance i_list[FINITE_LEVELS]={ 
-  {"mesh1", 1, "\"original\" board number one",   generate_mesh_1, 1.,1., 2 }, // 1
+  {"mesh1", 1, "a small beginning",        generate_mesh_1, 1.,1., 1 }, // 1
+  {"mesh1", 2, "a bit larger",             generate_mesh_1, 1.,1., 2 }, // 2
+  {"data" , 0, "canine... minus four",     generate_data,   1.,1.5,3 }, // 3
+  {"mesh1", 3, "much like level two",      generate_mesh_1, 1.,1., 3 }, // 4
 };
 
 #define LOOP_LEVELS 1
 static gen_instance i_list_loop[LOOP_LEVELS]={ 
-  {"mesh1", 2, "\"original\" board number %d",    generate_mesh_1, 1.,1., 2 }, // n
+  {"mesh1", 4, "\"original\" board number %d",    generate_mesh_1, 1.,1., 2 }, // n
 };
 
 int generate_find_number(char *id){
@@ -71,7 +74,7 @@
 
 	  // class match, determine the level number
 	  int order = atoi(arg+1);
-	  return FINITE_LEVELS + (order - i_list_loop[i].instancenum)*FINITE_LEVELS + i;
+	  return FINITE_LEVELS + (order - i_list_loop[i].instancenum)*LOOP_LEVELS + i;
 	
 	
 	}

Modified: trunk/planarity/graph_generate.h
===================================================================
--- trunk/planarity/graph_generate.h	2005-09-26 03:44:51 UTC (rev 10067)
+++ trunk/planarity/graph_generate.h	2005-09-26 05:31:56 UTC (rev 10068)
@@ -29,3 +29,4 @@
 extern void generate_board(graph *g,int num);
 
 extern void generate_mesh_1(graph *g, int order);
+extern void generate_data(graph *g, int order);

Added: trunk/planarity/graph_generate_data.c
===================================================================
--- trunk/planarity/graph_generate_data.c	2005-09-26 03:44:51 UTC (rev 10067)
+++ trunk/planarity/graph_generate_data.c	2005-09-26 05:31:56 UTC (rev 10068)
@@ -0,0 +1,106 @@
+/*
+ *
+ *  gPlanarity: 
+ *     The geeky little puzzle game with a big noodly crunch!
+ *    
+ *     gPlanarity copyright (C) 2005 Monty <monty at xiph.org>
+ *     Original Flash game by John Tantalo <john.tantalo at case.edu>
+ *     Original game concept by Mary Radcliffe
+ *
+ *  gPlanarity is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *   
+ *  gPlanarity is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *   
+ *  You should have received a copy of the GNU General Public License
+ *  along with Postfish; see the file COPYING.  If not, write to the
+ *  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "graph.h"
+#include "graph_generate.h"
+
+typedef struct d_vertex{
+  int x;
+  int y;
+} d_vertex;
+
+typedef struct d_edge{
+  int a;
+  int b;
+} d_edge;
+
+typedef struct d_level{
+  int obj;
+  int less;
+  d_vertex *v;
+  d_edge *e;
+} d_level;  
+
+static d_vertex v_level1[] = {
+  {400,30},  {143,216},  {241,518},  {559,518},  {657,216},
+  {282,138}, {210,362},  {400,500},  {590,362},  {518,138},
+  {-1,-1},
+};
+
+static d_edge e_level1[] = {
+  {0,5},  {5,1},  {0,2},  {0,3},  {0,9},  {9,4},  {1,6},  {6,2},
+  {1,3},  {1,4},  {2,7},  {7,3},  {2,4},  {3,8},  {8,4},{-1,-1},
+};
+
+static d_level leveldata[] = {
+  {1,0,v_level1,e_level1}
+
+
+
+};
+
+void generate_data(graph *g, int order){
+  int i;
+  d_level *l = leveldata+order;
+  vertex *vlist;
+  vertex **flat;
+
+  // scan for number of verticies
+  i=0;
+  while(l->v[i].x != -1)i++;
+  vlist=new_board(g, i);
+  flat = alloca(i*sizeof(*flat));
+
+  // build graph from data 
+  // add verticies
+  {
+    vertex *v=vlist;
+    i=0;
+    while(v){
+      v->x = l->v[i].x;
+      v->y = l->v[i].y;
+      flat[i++]=v;
+      v=v->next;
+    }
+  }
+  
+  // add edges
+  {
+    int i=0;
+    while(l->e[i].a != -1){
+      add_edge(g,flat[l->e[i].a],flat[l->e[i].b]);
+      i++;
+    }
+  }
+
+  g->objective = l->obj;
+  g->objective_lessthan = l->less;
+
+}
+

Modified: trunk/planarity/version.h
===================================================================
--- trunk/planarity/version.h	2005-09-26 03:44:51 UTC (rev 10067)
+++ trunk/planarity/version.h	2005-09-26 05:31:56 UTC (rev 10068)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Sun Sep 25 23:43:59 EDT 2005] */
+/* DO NOT EDIT: Automated versioning hack [Mon Sep 26 01:23:42 EDT 2005] */



More information about the commits mailing list