| ssjx.co.uk
Home of StormPlayer for Cybiko and other great programs |
| Home | Cybiko : Cybiko Guides : Cvc Videos | CyBorn | Amiga | Windows Games| Games| Links |
Bouncing BallThis program loads a sprite resource and bounces it arround the cybiko display. Direct keyboard is also used to allow the user to exit the program by pressing the space bar. The sprite is a 16x16 pic file that is put in the 'res' folder and then gets included in the actual app. You can download the app + source using the link below. If you have any comments about this tutorial, please use the DevCybiko / PlanetCybiko forums or personal messaging and let me know! What you will need
The Cybiko SDK Note: Don't type in the line numbers!
1 //
2 // Bouncing Ball by ssjx (7/8/6)
3 //
4
5 #include <cybiko.h>
6
7 struct module_t main_module;
8 struct DirectKeyboard* ptr_direct_keyboard;
9 struct Bitmap bmp;
10
11 long main(int argc, char *argv[],bool start)
12 {
13 int x,y,xdir=1,ydir=1,h,w,ext=0;
14
15 init_module(&main_module);
16
17 ptr_direct_keyboard = DirectKeyboard_get_instance();
18
19 x=20+random(120);
20 y=20+random(60);
21
22 TRACE("Loading sprite");
23 Bitmap_ctor_Ex1( &bmp,"ball.pic" );
24
25 h=Bitmap_get_h(&bmp);
26 w=Bitmap_get_w(&bmp);
27 TRACE("Sprite is %d x %d in size",w,h);
28
29 TRACE("Starting..");
30
31 while(ext==0)
32 {
33 TGraph_fill_screen( main_module.m_gfx, CLR_WHITE );
34 Graphics_draw_bitmap( main_module.m_gfx, &bmp, x, y, BM_NORMAL );
35 DisplayGraphics_show(main_module.m_gfx );
36
37 x+=xdir;
38 y+=ydir;
39
40 if ( (x+w)==160){xdir=-xdir;}
41 if ( (y+h)==100){ydir=-ydir;}
42 if (x==0){xdir=-xdir;}
43 if (y==0){ydir=-ydir;}
44
45 if ( DirectKeyboard_is_key_pressed( ptr_direct_keyboard, KEY_SPACE ) ){ext=1;}
46 }
47
48 TRACE("Finished");
49
50 DirectKeyboard_dtor( ptr_direct_keyboard, FREE_MEMORY );
51 Bitmap_dtor( &bmp, LEAVE_MEMORY );
52 return 0L;
53 }
How it works
|
| Links that help support site | |||
| RPoints | Buy from shops through RPoints and you can get money back. Includes Cdwow, Play.com, Dell and many other useful shops. | ||
| Top Cashback | Just like RPoints except they pay higher amounts on some shops. | ||
| Play-Asia | Very good online seller of games. They also stock a lot of retro games and consoles e.g. Saturn and Jaguar! | ||
| ©2008 ssjx |