# python version of e_tutorial.cpp
from a7 import *
lesson = 3
###############################################################################
if lesson == 1:
e = Engine("earth.mdl -nwnd -nc")
while e.frame():
pass
e.close()
###############################################################################
if lesson == 2:
e = Engine("-nwnd -nc")
e.fps_max = 50
camera = e.camera
add_folder("C:\Program Files (x86)\GStudio7\samples")
level_load("small.hmp")
while e.frame():
camera.pan += -3 * e.key_force.x
camera.tilt += 3 * e.key_force.y
move = Vector()
move.x = 6 * (e.key_w - e.key_s)
move.y = 6 * (e.key_a - e.key_d)
camera.position += move.rotate(camera.orientation)
e.close()
###############################################################################
if lesson == 3:
def plop():
ball.playsound(pong, 100)
def kick():
speed = Vector(150, 0, 0)
speed = speed.rotate(camera.orientation)
speed.z = 75
ball.ph_addvelcentral(speed)
plop()
e = Engine("-nwnd -nc")
e.shadow_stencil = 4
e.sound_vol = 100
camera = e.camera
add_folder("C:\Program Files (x86)\GStudio7\samples")
pong = Sound("tap.wav")
splash = Panel()
splash.bmap = Bitmap("digital.pcx")
splash.scale_x = float(e.screen_size.x) / splash.bmap.width()
splash.scale_y = float(e.screen_size.y) / splash.bmap.height()
splash.flags |= VISIBLE
for i in range(3): e.frame()
level_load("small.hmp")
ticks = 0
while ticks < 16:
ticks += e.time_step
e.frame()
splash.remove()
Entity("blood_gsmall+6.tga", flags2=SKY|CUBE, layer=0)
ball = Entity("earth.mdl", (0, 0, 100), None)
ball.ph_settype(PH_RIGID, PH_SPHERE)
ball.ph_setmass(1, PH_SPHERE)
ball.ph_setfriction(90)
ball.ph_setelasticity(75, 100)
ball.ph_setdamping(30, 5)
ball.ph_addvelcentral((2, 2, 0))
ball.flags |= SHADOW|CAST
ball.event = plop
ball.emask |= ENABLE_FRICTION
ph_setgravity((0, 0, -500))
e.on_space = kick
speed = Vector()
angular_speed = Vector()
while e.frame():
force = Vector()
force.x = -5 * (e.key_force.x + e.mouse_force.x)
force.y = 5 * (e.key_force.y + e.mouse_force.y)
move = vec_accelerate(angular_speed, force, 0.8)
camera.orientation += move
force.x = 6 * (e.key_w - e.key_s)
force.y = 6 * (e.key_a - e.key_d)
force.z = 6 * (e.key_home - e.key_end)
move = vec_accelerate(speed, force, 0.5)
camera.position += move.rotate(camera.orientation)
e.close()