Esempio n. 1
0
# Now we just display the level



# This function must be called the first time you run game_skel.
# Then, you can comment it, since the level has been saved.
create_level()

# Loads the level, and put it in the scene
level = soya.World.get("level_demo")
worlds.scene.add(level)

worlds.camera.set_xyz(697.0,5.0,545.0)
worlds.camera.back = 500
worlds.enable_fps = True

def mainloop():
	pass
#	print worlds.camera.x,worlds.camera.y,worlds.camera.z
	

def renderloop(proportion):
	if sdlconst.K_UP in worlds.KEY:			worlds.camera.z -= 1 * proportion
	if sdlconst.K_DOWN in worlds.KEY:		worlds.camera.z += 1 * proportion
	if sdlconst.K_LEFT in worlds.KEY:		worlds.camera.x -= 1 * proportion
	if sdlconst.K_RIGHT in worlds.KEY:	worlds.camera.x += 1 * proportion
	if sdlconst.K_SPACE in worlds.KEY:	worlds.camera.y += .5 * proportion
	if sdlconst.K_LCTRL in worlds.KEY:	worlds.camera.y -= .5 * proportion
	
worlds.begin_loop(mainloop,renderloop)
Esempio n. 2
0
w.init()

sword = PhysicsBody(mesh_file="sword")

sword.rotation[1]=90.0
sword.rotation[0]=17.0
sword.rotation[2]=3.0
w.camera.set_xyz(0,0,5)


time = 0

@sword.addloopcall
def swordloop(t):
    if t==0: return 0;	

    if K_UP in w.KEY: sword.rotation[0]+=200*t
    if K_DOWN in w.KEY: sword.rotation[0]-=200*t
    if K_LEFT in w.KEY: sword.rotation[1]+=200*t
    if K_RIGHT in w.KEY: sword.rotation[1]-=200*t
    if K_RSHIFT in w.KEY: sword.rotation[2]+=200*t
    if K_RCTRL in w.KEY: sword.rotation[2]-=200*t

    sword.rotation[0]/=1+0.50*t
    sword.rotation[1]/=1+0.50*t
    sword.rotation[2]/=1+0.50*t
    return t


w.begin_loop()
Esempio n. 3
0
        box3.model = box_mesh
        box4.model = box_mesh

    if c.K_1 in w.KEY: 
        box1.model = box_mesh2
        box2.model = box_mesh
        box3.model = box_mesh
        box4.model = box_mesh

    if c.K_2 in w.KEY: 
        box1.model = box_mesh
        box2.model = box_mesh2
        box3.model = box_mesh
        box4.model = box_mesh

    if c.K_3 in w.KEY: 
        box1.model = box_mesh
        box2.model = box_mesh
        box3.model = box_mesh2
        box4.model = box_mesh

    if c.K_4 in w.KEY: 
        box1.model = box_mesh
        box2.model = box_mesh
        box3.model = box_mesh
        box4.model = box_mesh2



w.begin_loop(callbackround=game_logic)
Esempio n. 4
0
	if soya.sdlconst.K_LEFT in w.KEY:	head.rotation[1]+=200
	if soya.sdlconst.K_RIGHT in w.KEY:	head.rotation[1]-=200
	head.rotation[1]/=1.5

	if soya.sdlconst.K_1 in w.KEY:	new_springfactor=0.1
	if soya.sdlconst.K_2 in w.KEY:	new_springfactor=0.2
	if soya.sdlconst.K_3 in w.KEY:	new_springfactor=0.4
	if soya.sdlconst.K_4 in w.KEY:	new_springfactor=0.8
	if soya.sdlconst.K_5 in w.KEY:	new_springfactor=1.6
	if soya.sdlconst.K_0 in w.KEY:	new_springfactor=0

	if new_springfactor != springfactor:
		global pieces
		for i in pieces:
			pieces[i].set_springfactor(new_springfactor)
		
		new_springfactor = springfactor
		
def renderloop(proportion):
	global head
	w.camera.look_at(head) 
	pass





w.begin_loop(mainloop, renderloop)


Esempio n. 5
0
        if result:
            impact, normal = result
            body_selected = impact.parent
            try:
                if body_selected.model == box_mesh1:
                    body_selected.model = box_mesh2
            except:
                pass            
            
        
        

def render_frame(proportion):
    global rounds, material
    diffuse1=[0,0,0,0]
    diffuse2=[0,0,0,0]
    rounds += proportion / 100.0
    import math
    diffuse1[0]=math.sin(rounds/10)/2+0.49
    diffuse1[1]=math.sin(rounds/3)/2+0.49
    diffuse1[2]=math.sin(rounds)/2+0.49
    material.diffuse   = tuple(diffuse1)

    diffuse2[0]=math.sin(rounds/10)/2+0.39
    diffuse2[1]=math.sin(rounds/6)/2+0.39
    diffuse2[2]=math.sin(rounds/2)/2+0.39
    material2.diffuse   = tuple(diffuse2)
    

w.begin_loop(callbackround=game_logic, callbackadvance=render_frame)
Esempio n. 6
0
box2.rotate_x(30)
box2.rotation[2]=50
box2.speed.y=-1


box3 = b.PhysicsBody(mesh=box_mesh)
box3.set_xyz(-1,0,-10)
box3.rotate_x(50)
box3.rotation[2]=30
box3.speed.y=-0.6



def game_logic():
    if 1 in w.MOUSE_BUTTON:
        button = w.MOUSE_BUTTON[1]
        box1.model = box_mesh
        box2.model = box_mesh
        box3.model = box_mesh
        mouse = w.camera.coord2d_to_3d(w.MOUSE_X, w.MOUSE_Y,-3)
        result = w.scene.raypick(w.camera, w.camera.vector_to(mouse))
        if result:
            impact, normal = result
            body_selected = impact.parent
            body_selected.model = box_mesh2
            
        


w.begin_loop(callbackround=game_logic,engine="pudding")
Esempio n. 7
0

box3 = b.PhysicsBody(mesh=box_mesh)
box3.set_xyz(-1,0,-10)
box3.rotate_x(50)
box3.rotation[2]=30
box3.speed.y=-0.6



def game_logic():
    if 1 in w.MOUSE_BUTTON:
        button = w.MOUSE_BUTTON[1]
        box1.model = box_mesh
        box2.model = box_mesh
        box3.model = box_mesh
        mouse = w.camera.coord2d_to_3d(w.MOUSE_X, w.MOUSE_Y,-3)
        result = w.scene.raypick(w.camera, w.camera.vector_to(mouse))
        if result:
            impact, normal = result
            body_selected = impact.parent
            body_selected.model = box_mesh2
            
def before_render(proportion):
    w.camera.width = w.camera.get_screen_width() / 2
    w.camera.left = w.camera.get_screen_width() / 2



w.begin_loop(callbackround=game_logic,callbackadvance=before_render, engine="pudding")