×

Discussion Board

Results 1 to 15 of 47

Threaded View

  1. #31
    Registered User
    Join Date
    Jan 2012
    Posts
    36

    Re: Maybe We Should Have A Pys60 Game Engine

    Found another source code that I had to edit so it can be executed on my 5230 which should somewhat solve one of the previous conflicts...

    Code:
    # py60snowfall.py
    
    import e32,audio,appuifw,os,sys,key_codes,time,math,random,graphics,sensor
    import sysinfo
    
    xscr=sysinfo.display_pixels()[1]
    yscr=sysinfo.display_pixels()[0]
    nflakes=240
    imgSnow=8
    WHITE=0xffffff
    BLUE=0x000080
    
    moveX=range(nflakes)
    moveY=range(nflakes)
    XX=range(nflakes)
    YY=range(nflakes)
    
    for i in range(nflakes):
    	moveY[i]=random.randint(1,24)
    	dir=random.choice([-1,1])
    	moveX[i]=dir*random.randint(1,3)
    	XX[i]=random.randint(0,xscr)
    	YY[i]=random.randint(0,yscr)
    
    def falling():
    	global moveX,moveY,XX,YY
    	img.clear(BLUE)
    	for i in range(nflakes):
    		dir=random.choice([-1,1])
    		moveX[i]=dir*moveX[i]
    		XX[i]=XX[i]+moveX[i]
    		YY[i]=YY[i]+moveY[i]
    		if((XX[i]>xscr)or(XX[i]<0)):
    			moveX[i]=-moveX[i]
    		if(YY[i]>yscr):
    			moveY[i]=random.randint(1,24)
    			dir=random.choice([-1,1])
    			moveX[i]=dir*random.randint(1,3)
    			XX[i]=random.randint(0,xscr)
    			YY[i]=dir*random.randint(1,24)
    		img.ellipse([(XX[i],YY[i]),(XX[i]+imgSnow,YY[i]+imgSnow)],WHITE,fill=WHITE)
    	canvas.blit(img,(0,0))
    	timer.after(0.1,falling)
    	draw(img)
    
    def draw(rect):
    	appuifw.e32.reset_inactivity()
    
    def exit(pos):
    	app_lock.signal()
    
    img=graphics.Image.new((xscr,yscr))
    appuifw.app.directional_pad=False
    canvas=appuifw.Canvas(redraw_callback=draw)
    appuifw.app.body=canvas
    canvas.bind(key_codes.EButton1Down,exit)
    appuifw.app.screen='full'
    
    timer=appuifw.e32.Ao_timer()
    appuifw.app.orientation='portrait'
    falling()
    e32.ao_yield()
    
    app_lock=appuifw.e32.Ao_lock()
    app_lock.wait() 
    timer.cancel()
    Last edited by all2happy; 2012-09-06 at 03:25.

Similar Threads

  1. 3D Game engine for MIDP/M3G
    By mcwo in forum Mobile Java General
    Replies: 8
    Last Post: 2010-05-28, 03:24
  2. HandleKeyEventL Game Engine
    By TheCyclops in forum Symbian
    Replies: 4
    Last Post: 2003-08-06, 09:45
  3. Game engine coming along nicely...
    By aehrath in forum Symbian
    Replies: 0
    Last Post: 2003-07-08, 18:53
  4. Replies: 0
    Last Post: 2003-07-02, 17:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×