annotate examples/dynamic/hello.c @ 427:8f900da42eed

Make sh_text_draw() passes first test case.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 28 Jul 2009 15:11:42 +0800
parents 31b6633e3538
children 84ce2d4a8c3f
rev   line source
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
1 /*! \file
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
2 *
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
3 * svg2code_ex is an example that show programmers how to create a
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
4 * menu with MadButterfly.
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
5 *
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
6 */
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
7 #include <stdio.h>
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
8 #include <mb.h>
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
9 #include <string.h>
387
433fa83d16f9 Corrected build dependence - able to build in Ubuntu Intrepid
Ben Lau <xbenlau@gmail.com>
parents: 247
diff changeset
10 //#include "menu.h"
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
11 #include "mbapp.h"
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
12
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
13
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
14 MBApp *myApp;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
15
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
16 typedef struct {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
17 shape_t *rect;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
18 co_aix orx,ory;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
19 int start_x,start_y;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
20 observer_t *obs1,*obs2;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
21 int currentscene;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
22 }MyAppData;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
23
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
24
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
26 {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
27 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData );
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
28 mb_timeval_t timer,interval;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
29
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
30
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
31 get_now(&timer);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
32 MB_TIMEVAL_SET(&interval, 1 ,0);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
33 MB_TIMEVAL_ADD(&timer, &interval);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
34 mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
35
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
36 en->currentscene = (en->currentscene + 1) % 2;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
37 printf("switch to scene %d\n", en->currentscene + 1);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
38 MB_SPRITE_GOTO_SCENE(myApp->rootsprite,en->currentscene + 1);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
39 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
40
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
41 int main(int argc, char * const argv[]) {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
42 subject_t *subject;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
43 mb_button_t *b;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
44 mb_obj_t *button;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
45 MyAppData data;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
46 mb_timeval_t tmo,interval;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
47
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
48 if (argc > 1)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
49 myApp = MBApp_Init(argv[1]);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
50 else
399
31b6633e3538 - Fix a minor error in src/sprite.c: should check *(s-1) instead of
john.cylee@gmail.com
parents: 387
diff changeset
51 myApp = MBApp_Init(".libs/scene");
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
52 data.currentscene=0;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
53 MBApp_setData(myApp,&data);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
54 //b = mb_button_new(myApp, myApp->rootsprite, "btn");
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
55 //mb_button_add_onClick(b, test,NULL);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
56 get_now(&tmo);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
57 MB_TIMEVAL_SET(&interval, 1 ,0);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
58 mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
59
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
60
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
61 MBApp_loop(myApp);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
62
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
63 return 0;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
64 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
65
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
66 /* vim: set ts=4 */