#*************************# # CamelCrusaders v 2.0.0 # # Sept. 21, 2007 # #*************************# #*************************# import sys, math, random, time from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from OpenGL.GLX import * from copy import deepcopy from Image import * gamepause = False debugmode = -1 #-1-off, 0-all, 1-input, 2-offsets, 3-system, 3.5-spf, 4-temp, 5-track, 6-loc, 7-exactloc 11-all, 12-off winx = 1260 winy = 925 #Camera Vars #System Vars #EnviroVars #Movement Vars #Map Vars #Objects #Textures def main(toDEBUG): #Initialize everything, set call methods, load textures, set window settings def LoadTextures(): #Loads all textures #******************************************************# #DDDD IIIIII SSSS PPPP LL AA YY YY# #DD DD II SS PP PP LL AA AA YY YY# #DD DD II SS PPPP LL AAAAAA YY # #DD DD II SS PP LL AA AA YY # #DDDD IIIIII SSSS PP LLLLLL AA AA YY # #******************************************************# def display(): #Count Frames, etc #Draw Terrain if not(funcmode): txoffset = math.floor(camerax / landsize) tyoffset = math.floor(cameray / landsize) drawterrain(landhts, txoffset, tyoffset, True) neartxoffset = txoffset + nearx neartyoffset = tyoffset + neary drawterrain(landhtsnearx, neartxoffset, tyoffset, False) drawterrain(landhtsneary, txoffset, neartyoffset, False) drawterrain(landhtsnearxy, neartxoffset, neartyoffset, True) drawlandscape() else: drawfunc() #drawlandscape() global lions, Bombs #Calculate Motion Physics #ACT METHOD act() #draw axes #DRAW OBJECTS if maptog: #Draw game map #******************************************************# #******************************************************# #******************************************************# #******************************************************# def act(): global lions, Bombs for each in lions: actlion(each) for each in Bombs: actBomb(each) def reshape(width, height): #Sets perspective def normalkeys(key, x, y): #Reads key inputs def releasekeys(key, x, y): global keys if keys.has_key(key): if keys[key] == 1: keys[key] = 0 def specialkeys(key, x, y): global gamepause, debugmode if gamepause: return debug(1,key) if key>0 and key<13: debugmode = key def mousemotionRead(x,y): #Changes view angle with mouse def drawfunc(): method = 3 #0-local, 1-diminishing squares, 2-constant squares, 3-circular if method == 0: tfunc0() if method == 1: tfunc1() if method == 2: tfunc2() if method ==3: tfunc3() def tfunc3(): #Renders terrain in different textures def terrainfunc(absx, absy): scale = 10 absx += 30000 wxo = 1.5+0.5*math.sin(absy/1000.0) warpx = 50.0*math.sin(absy/(10.0*scale*wxo)) absx += warpx htx = 45*scale*math.sin((absx/(1000.0*scale))) widx = abs(200*scale*math.sin((absx)/(1000.0*scale))) if widx<50*scale: widx = 50.0*scale terrx = htx*math.sin((absx)/widx) hty = 45*scale*math.sin((absy/(1000.0*scale))) widy = abs(200*scale*math.sin((absy)/(1000.0*scale))) if widy<50*scale: widy = 50.0*scale terry = hty*math.sin((absy)/widy) xprop = 0.3*math.sin((math.sqrt(absx*absx+absy*absy))/(35*scale))+0.5 yprop = 1-xprop fht = terrx*xprop + terry*yprop #fht = terrainfunc2(fht, fht, 0)+800 #100000 in every direction (0,30000) extreme (290400,-41200) return fht def terrainfunc2(absx, absy, count): #Recursive terrain function def drawlion(lion): #800 lines of Lion rendering code def debug(mode, dstring): global debugmode if ((mode == debugmode) or (debugmode == 11) or (debugmode == 0)) and not(debugmode == -1): print dstring #Determines whether to print different kinds of debug outputs class Bomb: def __init__(self, s, tx, ty, tz, tvz, tvx, tvy): #Creates a new bomb of a given size def drawBomb(t): #Renders Bomb model def actBomb(t): #Controls Bomb physics, flashing, explosion, and afterwards class Lion: def __init__(self, tx, ty, tz): #Creates a new lion object def actlion(l): #Controls lion physics and AI DEBUG = True main(DEBUG)