main.py
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 import sys
00014 import list
00015 from ma import *
00016
00017
00018
00019 print "MoPync - bringing the Guido goodness to the world of MoSync"
00020
00021 LOGO_HANDLE = 1
00022 logo_width, logo_height = maGetImageSize(LOGO_HANDLE)
00023
00024 screen_width, screen_height = maGetScrSize()
00025 background_color = 0x330055
00026
00027
00028 rectangles = []
00029 for _ in xrange(10):
00030 list.append(rectangles, [rand() % screen_width, rand() % screen_height,
00031 rand() % 40 + 20, rand() % 40 + 20,
00032 (rand() % 0x40) * 0x10002 + 0x883388,
00033 rand() % 7 - 3, rand() % 7 - 3])
00034
00035
00036
00037 maSetColor(background_color)
00038 maFillRect(0, 0, screen_width, screen_height)
00039
00040 keep_going = True
00041 while keep_going:
00042 sys.gc()
00043
00044 maWait(1)
00045
00046
00047 for event in maGetEvents():
00048 print event.__str__()
00049 if (event.type == EVENT_TYPE_CLOSE or
00050 event.type == EVENT_TYPE_KEY_PRESSED and event.key == MAK_FIRE):
00051 keep_going = False
00052
00053
00054 maSetColor(background_color)
00055 for rectangle in rectangles:
00056 x, y, w, h, c, xv, yv = rectangle
00057 maFillRect(x-w, y-h, w, h)
00058
00059
00060 maFillRect(screen_width-logo_width >> 1,
00061 screen_height-logo_height >> 1,
00062 logo_width, logo_height)
00063
00064
00065 for rectangle in rectangles:
00066 x, y, w, h, c, xv, yv = rectangle
00067 rectangle[0] += xv + screen_width + w
00068 rectangle[0] %= screen_width + w
00069 rectangle[1] += yv + screen_height + h
00070 rectangle[1] %= screen_height + h
00071
00072
00073 maDrawImage(LOGO_HANDLE,
00074 screen_width-logo_width >> 1,
00075 screen_height-logo_height >> 1)
00076
00077
00078 for rectangle in rectangles:
00079 x, y, w, h, c, xv, yv = rectangle
00080 maSetColor(c)
00081 maFillRect(x-w, y-h, w, h)
00082
00083 maUpdateScreen()
00084