[xiph-commits] r10069 - trunk/planarity

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sun Sep 25 23:32:50 PDT 2005


Author: xiphmont
Date: 2005-09-25 23:32:47 -0700 (Sun, 25 Sep 2005)
New Revision: 10069

Modified:
   trunk/planarity/dialog_finish.c
   trunk/planarity/dialog_finish.h
   trunk/planarity/graph_arrange.c
   trunk/planarity/graph_arrange.h
   trunk/planarity/graph_generate.c
   trunk/planarity/graph_generate.h
   trunk/planarity/graph_generate_mesh1.c
   trunk/planarity/version.h
Log:
The first few interesting levels!



Modified: trunk/planarity/dialog_finish.c
===================================================================
--- trunk/planarity/dialog_finish.c	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/dialog_finish.c	2005-09-26 06:32:47 UTC (rev 10069)
@@ -174,7 +174,7 @@
     render_bordertext_centered(c,buffer, w/2,y);y+=24;
 
 
-    snprintf(buffer,160,"Objective: %d points",graphscore_get_score(&g->g));
+    snprintf(buffer,160,"Base score: %d points",graphscore_get_score(&g->g));
     render_bordertext_centered(c,buffer, w/2,y);y+=24;
 
     snprintf(buffer,160,"Time bonus: %d points",time_bonus);

Modified: trunk/planarity/dialog_finish.h
===================================================================
--- trunk/planarity/dialog_finish.h	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/dialog_finish.h	2005-09-26 06:32:47 UTC (rev 10069)
@@ -26,7 +26,7 @@
 
 #define FINISH_BUTTON_BORDER 35
 #define FINISH_BUTTON_Y 25
-#define FINISHBOX_WIDTH 220
+#define FINISHBOX_WIDTH 250
 #define FINISHBOX_HEIGHT 330
 
 extern void finish_level_dialog(Gameboard *g);

Modified: trunk/planarity/graph_arrange.c
===================================================================
--- trunk/planarity/graph_arrange.c	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/graph_arrange.c	2005-09-26 06:32:47 UTC (rev 10069)
@@ -30,7 +30,7 @@
 #include "gameboard.h"
 #include "graph_arrange.h"
 
-void arrange_verticies_circle(graph *g){
+void arrange_verticies_circle(graph *g, float off1, float off2){
   vertex *v = g->verticies;
   int n = g->vertex_num;
   int bw=g->orig_width;
@@ -38,8 +38,8 @@
   int radius=min(bw,bh)*.45;
   int i;
   for(i=0;i<n;i++){
-    v->x = rint( radius * cos( i*M_PI*2./n) + (bw>>1));
-    v->y = rint( radius * sin( i*M_PI*2./n) + (bh>>1));
+    v->x = rint( radius * cos( i*M_PI*2./n +off1) + (bw>>1));
+    v->y = rint( radius * sin( i*M_PI*2./n +off2) + (bh>>1));
     v=v->next;
   }
 }

Modified: trunk/planarity/graph_arrange.h
===================================================================
--- trunk/planarity/graph_arrange.h	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/graph_arrange.h	2005-09-26 06:32:47 UTC (rev 10069)
@@ -24,5 +24,5 @@
  * 
  */
 
-extern void arrange_verticies_circle(graph *g);
+extern void arrange_verticies_circle(graph *g, float off1, float off2);
 extern void arrange_verticies_mesh(graph *g, int width, int height);

Modified: trunk/planarity/graph_generate.c
===================================================================
--- trunk/planarity/graph_generate.c	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/graph_generate.c	2005-09-26 06:32:47 UTC (rev 10069)
@@ -40,17 +40,20 @@
   int unlock;
 } gen_instance;
 
-#define FINITE_LEVELS 3
+#define FINITE_LEVELS 7
 static gen_instance i_list[FINITE_LEVELS]={ 
-  {"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
+  {"mesh1", 1, "A Small Beginning",           generate_mesh_1,  1.,1., 1 }, // 1
+  {"mesh1", 2, "My First Real Level(tm)",     generate_mesh_1,  1.,1., 2 }, // 2
+  {"data" , 0, "My First Mission Impossible(tm)",  generate_data,    1.,1.5,3 }, // 3
+  {"mesh1", 3, "Larger, Not Harder",          generate_mesh_1,  1.,1., 3 }, // 4
+  {"meshC", 5, "The Trick Is It's Easy",      generate_mesh_1C, 1.,1., 2 }, // 5
+  {"meshM", 6, "If You Squint, It's A Brick", generate_mesh_1M, 1.,1., 1 }, // 6
+  {"mesh1", 7, "Round But Straightforward",   generate_mesh_1,  1.,1., 3 }, // 7
 };
 
 #define LOOP_LEVELS 1
 static gen_instance i_list_loop[LOOP_LEVELS]={ 
-  {"mesh1", 4, "\"original\" board number %d",    generate_mesh_1, 1.,1., 2 }, // n
+  {"mesh1", 8, "\"Original\" Board Number %d",    generate_mesh_1, 1.,1., 2 }, // n
 };
 
 int generate_find_number(char *id){

Modified: trunk/planarity/graph_generate.h
===================================================================
--- trunk/planarity/graph_generate.h	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/graph_generate.h	2005-09-26 06:32:47 UTC (rev 10069)
@@ -29,4 +29,7 @@
 extern void generate_board(graph *g,int num);
 
 extern void generate_mesh_1(graph *g, int order);
+extern void generate_mesh_1M(graph *g, int order);
+extern void generate_mesh_1C(graph *g, int order);
+
 extern void generate_data(graph *g, int order);

Modified: trunk/planarity/graph_generate_mesh1.c
===================================================================
--- trunk/planarity/graph_generate_mesh1.c	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/graph_generate_mesh1.c	2005-09-26 06:32:47 UTC (rev 10069)
@@ -26,6 +26,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <math.h>
 
 #include "graph.h"
 #include "random.h"
@@ -205,11 +206,10 @@
   }
 }
 
-void generate_mesh_1(graph *g, int order){
+static void generate_mesh(graph *g, mesh *m, int order, int density_128){
   int flag=0;
-  mesh m;
-  m.width=3;
-  m.height=2;
+  m->width=3;
+  m->height=2;
   vertex *vlist;
 
   random_seed(order);
@@ -217,40 +217,60 @@
     while(--order){
       if(flag){
 	flag=0;
-	m.height+=1;
+	m->height+=1;
       }else{
 	flag=1;
-	m.width+=2;
+	m->width+=2;
       }
     }
   }
 
-  vlist=new_board(g, m.width * m.height);
+  vlist=new_board(g, m->width * m->height);
 
   /* a flat vector is easier to address while building the mesh */
   {
     int i;
     vertex *v=vlist;
-    m.v=alloca(m.width*m.height * sizeof(*m.v));
-    for(i=0;i<m.width*m.height;i++){
-      m.v[i]=v;
+    m->v=alloca(m->width*m->height * sizeof(*m->v));
+    for(i=0;i<m->width*m->height;i++){
+      m->v[i]=v;
       v=v->next;
     }
   }
 
   /* first walk a random spanning tree */
-  span_depth_first(g, 0, &m);
+  span_depth_first(g, 0, m);
   
   /* now iterate the whole mesh adding random edges */
   {
     int i;
-    for(i=0;i<m.width*m.height;i++)
-      random_populate(g, i, &m, 2, 32);
+    for(i=0;i<m->width*m->height;i++)
+      random_populate(g, i, m, 2, density_128);
   }
 
+  g->objective=0;
+  g->objective_lessthan=0;
+
+}
+
+void generate_mesh_1(graph *g, int order){
+  mesh m;
+  generate_mesh(g,&m,order,32);
   randomize_verticies(g);
-  arrange_verticies_circle(g);
+  arrange_verticies_circle(g,0,0);
+}
 
-  //arrange_verticies_mesh(m.width,m.height);
+void generate_mesh_1M(graph *g, int order){
+  mesh m;
+  generate_mesh(g,&m,order,32);
+  randomize_verticies(g);
+  arrange_verticies_mesh(g,m.width,m.height);
 }
 
+void generate_mesh_1C(graph *g, int order){
+  int n;
+  mesh m;
+  generate_mesh(g,&m,order,128);
+  n=m.width*m.height;
+  arrange_verticies_circle(g,M_PI/n - M_PI/2,M_PI/n - M_PI/2);
+}

Modified: trunk/planarity/version.h
===================================================================
--- trunk/planarity/version.h	2005-09-26 05:31:56 UTC (rev 10068)
+++ trunk/planarity/version.h	2005-09-26 06:32:47 UTC (rev 10069)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Mon Sep 26 01:23:42 EDT 2005] */
+/* DO NOT EDIT: Automated versioning hack [Mon Sep 26 02:31:31 EDT 2005] */



More information about the commits mailing list