diff examples/tank/tank_main.c @ 122:17e97e92b76e

Encapsulate X_MB_runtime_t and support X keyboard events.
author Thinker K.F. Li <thinker@branda.to>
date Mon, 15 Sep 2008 20:33:06 +0800
parents 5df7403b6fbc
children ba581d8a4b9b
line wrap: on
line diff
--- a/examples/tank/tank_main.c	Sun Sep 14 23:40:57 2008 +0800
+++ b/examples/tank/tank_main.c	Mon Sep 15 20:33:06 2008 +0800
@@ -54,6 +54,7 @@
 void
 initial_tank(tank_rt_t *tank_rt, X_MB_runtime_t *mb_rt) {
     redraw_man_t *rdman;
+    mb_tman_t *tman;
     mud_t *mud;
     brick_t *brick;
     rock_t *rock;
@@ -63,7 +64,7 @@
     mb_timeval_t mbtv;
     int i, j;
 
-    rdman = mb_rt->rdman;
+    rdman = X_MB_rdman(mb_rt);
 
     tank_rt->mb_rt = mb_rt;
     for(i = 0; i < 12; i++) {
@@ -119,20 +120,21 @@
     mb_shift_new(0, 150, tank_rt->tank1->root_coord, word);
     mb_shift_new(0, 150, tank_rt->tank2->root_coord, word);
 
+    tman = X_MB_tman(mb_rt);
     get_now(&mbtv);
-    mb_progm_start(tank_rt->tank1_progm, mb_rt->tman, &mbtv);
+    mb_progm_start(tank_rt->tank1_progm, tman, &mbtv);
 }
 
 int
 main(int argc, char *const argv[]) {
-    X_MB_runtime_t rt;
+    X_MB_runtime_t *rt;
     tank_rt_t tank_rt;
 
-    X_MB_init(":0.0", 800, 600, &rt);
+    rt = X_MB_new(":0.0", 800, 600);
 
-    initial_tank(&tank_rt, &rt);
+    initial_tank(&tank_rt, rt);
     
-    X_MB_handle_connection(&rt);
+    X_MB_handle_connection(rt);
 
-    X_MB_destroy(&rt);
+    X_MB_free(rt);
 }