Here's what I'm working on so far -- I have some basic movement (no collisions yet though) and some scenery to fly past. I'm using DBP's shadow shading to achieve some shadows, but I'm a bit concerned about the FPS...
For me it dips occasionally when I fly over a building, which really worries me considering I haven't even put in any collision or gameplay in it yet. Anyone here wanna have a shot with it and tell me what kind of results you're getting?
I really need
some sort of shadows in the game to help judge distance, I don't want players becoming frustrated because they crash into the ground without realizing, yet I'm starting to think DBP's default shadows are not the way to go. Of course, it could just be my laptop but I want to get some other opinions.
` *********************
` *** Game Settings ***
` *********************
#constant matrixSize = 25
#constant scrollSpeed = 1.5
` ***********************
` *** Screen Settings ***
` ***********************
sync on : sync rate 60
backdrop on : color backdrop rgb(0, 0, 32)
set display mode 800, 600, 32
autocam off
set image colorkey 255, 0, 255
set ambient light 50
` Game Initialization
gosub GameInit
` Start a new game
gosub NewGame
` *****************
` *** Main Loop ***
` *****************
ink rgb(255, 255, 255), 0
do
set cursor 0, 0
print screen fps()
` Control player
gosub UpdatePlayer
` Update camera
gosub UpdateCamera
` Scroll landscape
gosub WrapMatrix
`position object sph, cam.x, get ground height(1, cam.x-matrix.x, 0-matrix.z)+20, 0
if cam.x - object position x(houseObj1) > 250
position object houseObj1, cam.x+250, 0, 0
yrotate object houseObj1, rnd(45)-rnd(45)
endif
` Refresh
sync
loop
` ************************
` *** In-Game Handling ***
` ************************
` Erase the current level and build a new one
NewLevel:
` Erase all resources from previous level
gosub ClearAll
` Generate all media to be used in-game
gosub GenerateMedia
` Generate the world
gosub GenerateWorld
` Reset the player
player.deer.x = 25 : player.deer.y = 100
player.deer.xSpeed = 0.0 : player.deer.ySpeed = 0.0
player.sleigh.x = -25 : player.sleigh.y = 100
player.sleigh.xSpeed = 0.0 : player.sleigh.ySpeed = 0.0
` Reset the camera
cam.x = 0 : cam.y = 40 : cam.z = -150
return
` Call various texture and object creation subs to generate media
GenerateMedia:
` Build world textures
gosub MakeWorldTextures
` Create main house objects to be used for cloning
gosub MakeHouseTextures
houseObj1 = BuildHouse1()
position object houseObj1, 250, 0, 0
yrotate object houseObj1, rnd(45)-rnd(45)
` Create player reindeer object
gosub MakeReindeerTextures
player.deer.obj = BuildReindeer()
set shadow shading on player.deer.obj, -1, 250, 1
` Create player sleigh object
gosub MakeSleighTextures
player.sleigh.obj = BuildSleigh()
position object player.sleigh.obj, 250, 75, 0
set shadow shading on player.sleigh.obj, -1, 250, 1
`make light 1 : set light range 1, 100 : color light 1, rgb(255, 0, 0)
return
` Prepare world objects (matrix, trees, scenery, etc)
GenerateWorld:
` Create a new matrix and populate it with hills
gosub MakeMatrix
gosub ResetMatrix
gosub MatrixHills
gosub MatrixHeights
gosub MatrixNormals
` Fog settings
set camera range 1, 500
fog on : fog distance 500 : fog color rgb(0, 0, 32)
return
` Perform all player-related subs
UpdatePlayer:
` Control the reindeer
gosub ControlDeer
` Control the sleigh
gosub ControlSleigh
` Animate both player objects
gosub AnimatePlayer
return
` Control the player reindeer with arrow keys
ControlDeer:
` Deer is always moving to the right
inc player.deer.x, scrollSpeed
` Get keyboard input
moveX = rightkey()-leftkey()
moveY = upkey()-downkey()
` Increase speeds based on keyboard control
inc player.deer.xSpeed, moveX*0.1
inc player.deer.ySpeed, moveY*0.1
` Cap max speeds
if abs(player.deer.xSpeed) > 2.0 then player.deer.xSpeed = 2.0*Sign(player.deer.xSpeed)
if abs(player.deer.ySpeed) > 2.0 then player.deer.ySpeed = 2.0*Sign(player.deer.ySpeed)
` Apply friction to the speed
player.deer.xSpeed = player.deer.xSpeed * 0.95
player.deer.ySpeed = player.deer.ySpeed * 0.95
` If either speed reaches a significantly small number, reset it back to zero
if abs(player.deer.xSpeed) < 0.01 then player.deer.xSpeed = 0.0
if abs(player.deer.ySpeed) < 0.01 then player.deer.ySpeed = 0.0
` Update position based on speed
inc player.deer.x, player.deer.xSpeed
inc player.deer.y, player.deer.ySpeed
` Update deer object
position object player.deer.obj, player.deer.x, player.deer.y, 0
return
` Pull Santa's sleigh along with the reindeer
ControlSleigh:
` Sleigh is always moving to the right
inc player.sleigh.x, scrollSpeed
` Sleigh should be "elastically" connected -50x units from reindeer
xDif# = (player.deer.x-50) - player.sleigh.x
yDif# = player.deer.y - player.sleigh.y
` Increase speeds based distance from sleigh
inc player.sleigh.xSpeed, xDif#*0.005
inc player.sleigh.ySpeed, yDif#*0.005
` Increase the speed a bit more if the sleigh is riding up the reindeer
if abs(player.deer.x-player.sleigh.x) < 45.0 and player.deer.xSpeed < 0.0
inc player.sleigh.xSpeed, xDif#*0.01
endif
` Cap max speeds
if abs(player.sleigh.xSpeed) > 4.0 then player.sleigh.xSpeed = 4.0*Sign(player.sleigh.xSpeed)
if abs(player.sleigh.ySpeed) > 4.0 then player.sleigh.ySpeed = 4.0*Sign(player.sleigh.ySpeed)
` Apply friction to the speed
player.sleigh.xSpeed = player.sleigh.xSpeed * 0.95
player.sleigh.ySpeed = player.sleigh.ySpeed * 0.95
` If either speed reaches a significantly small number, reset it back to zero
if abs(player.sleigh.xSpeed) < 0.0001 then player.sleigh.xSpeed = 0.0
if abs(player.sleigh.ySpeed) < 0.0001 then player.sleigh.ySpeed = 0.0
` Update position based on speed
inc player.sleigh.x, player.sleigh.xSpeed
inc player.sleigh.y, player.sleigh.ySpeed
` Update the sleigh object
position object player.sleigh.obj, player.sleigh.x, player.sleigh.y, 0
return
` Animate the sleigh and the reindeer objects
AnimatePlayer:
` ** Deer Animations **
` Update animation frame
player.deer.ani = wrapvalue(player.deer.ani + 4.5)
` Rotate the deer as it moves up and down
player.deer.zAng = (player.deer.ySpeed/2.0)*30.0
` Oscillate the deer's body in the wind
player.deer.xAng = sin(player.deer.ani)*3.0
inc player.deer.zAng, cos(player.deer.ani)*3.0
` Animate deer's limbs
rotate limb player.deer.obj, deerNeck, 0, 0, sin(player.deer.ani)*3
rotate limb player.deer.obj, deerHead, 0, 0, sin(player.deer.ani)*3
rotate limb player.deer.obj, deerLegFL, 0, 0, sin(player.deer.ani)*15
rotate limb player.deer.obj, deerLegFR, 0, 0, cos(player.deer.ani)*15
rotate limb player.deer.obj, deerLegBL, 0, 0, sin(player.deer.ani)*-15
rotate limb player.deer.obj, deerLegBR, 0, 0, cos(player.deer.ani)*-15
` Update deer object
rotate object player.deer.obj, player.deer.xAng, 0, player.deer.zAng
` Update reindeer's nose
`position light 1, player.deer.x+25, player.deer.y, 0
` ** Sleigh / Santa Animations **
` Update animation frames
player.sleigh.ani = wrapvalue(player.sleigh.ani + 3.5)
player.sleigh.headAni = wrapvalue(player.sleigh.headAni + 1.0)
player.sleigh.handAni = wrapvalue(player.sleigh.handAni + 2.0)
` Rotate the sleigh as it moves up and down
player.sleigh.zAng = (player.sleigh.ySpeed/4.0)*30.0
` Oscillate the sleigh in the wind
player.sleigh.xAng = sin(player.sleigh.ani)*3.0
inc player.sleigh.zAng, cos(player.sleigh.ani)*3.0
` Animate Santa's head and hands
rotate limb player.sleigh.obj, santaHead, 0, 0, sin(player.sleigh.headAni)*15.0
rotate limb player.sleigh.obj, santaHandL, 0, (sin(player.sleigh.handAni)*4.0)-4, 0
rotate limb player.sleigh.obj, santaHandR, 0, (cos(player.sleigh.handAni)*4.0)-4, 0
` Update the sleigh object
rotate object player.sleigh.obj, player.sleigh.xAng, 0, player.sleigh.zAng
` ** Update Shadows **
`position light 1, cam.x-200, cam.y+200, 0
set shadow position -1, cam.x-200, cam.y+200, 0
return
` Move the camera along with the player
UpdateCamera:
` Camera is always moving to the right
inc cam.x, scrollSpeed
` Follow the player sleigh with the camera
cam.y = Min(player.deer.y, 150)
` Don't allow camera to move too close to ground
if cam.y < 40 then cam.y = 40
` Update the camera
position camera cam.x, cam.y, cam.z
point camera cam.x, Min(player.deer.y, 150), 0
return
` ***************************
` *** Game Initialization ***
` ***************************
` Prepare global variables and arrays that will be used for the whole game
GameInit:
` Declare UDTs
gosub SetupUDTs
` ** In-Game Object Variables **
` Setup camera variable
global cam as posType
` ** World Variables **
` Setup matrix variables
global matrix as posType
global dim matrixHeight#(matrixSize, matrixSize)
` ** Player Variables **
global player as playerType
` ** Media Variables **
` World variables
global worldSnowImg, worldSkyImg
` Reindeer variables
global deerFurImg, deerTailImg, deerNeckImg, deerHeadImg, deerNoseImg, deerAntlerImg, deerLegImg
` Sleigh and Santa variables
global sleighFloorImg, sleighRightImg, sleighLeftImg, sleighBackImg, sleighFrontImg
global sleighBladeLImg, sleighBladeRImg, sleighSackImg, sleighSackTopImg
global santaBodyImg, santaHeadImg, santaNoseImg, santaBeardImg, santaHalfHatImg, santaHatImg, santaHandImg
` House variables
global houseObj1 as integer
global houseFrontImg, houseSideImg, houseAtticImg, houseRoofImg, houseLightOnImg
return
` Prepare all user-defined-types that will be used by global variables
SetupUDTs:
` Type for general object placement
type posType
` Object handling
obj as integer
` Position
x as float
y as float
z as float
xAng as float
yAng as float
zAng as float
endtype
` Player reindeer type
type deerType
` Object handling
obj as integer
` Position and movement
x as float
y as float
xAng as float
zAng as float
xSpeed as float
ySpeed as float
` Misc info
ani as float ` Animation frame (deer legs and body angle)
endtype
` Player sleigh type
type sleighType
` Object handling
obj as integer
` Position and movement
x as float
y as float
xAng as float
zAng as float
xSpeed as float
ySpeed as float
` Misc info
ani as float ` Animation frame (sleigh angle)
headAni as float ` Animation frame (head turning)
handAni as float ` Animation frame (hands moving)
endtype
` Main player type
type playerType
` Reindeer variables (the object player directly controls)
deer as deerType
` Sleigh variables (follows deer and drops presents)
sleigh as sleighType
` General variables
status as integer ` 1 = Normal, 0 = Hurt
endtype
return
` Get ready to start the first level of the game
NewGame:
` Start the first level
gosub NewLevel
return
` *************
` *** World ***
` *************
` Clear the matrix for a clean slate
ResetMatrix:
for x = 0 to matrixSize
for z = 0 to matrixSize
matrixHeight#(x, z) = 0.0
next z
next x
matrix.x = -(matrixSize*20) : matrix.z = -200
position matrix 1, matrix.x, 0, matrix.z
return
` Populate the matrix with snowy banks
MatrixHills:
randomize timer()
` Add hills to the matrix
for i = 1 to 100
` Pick a random spot, size, and height for this hill
x = rnd(matrixSize) : z = rnd(matrixSize)
size = 1+rnd(3) : maxH# = 10.0+rnd(10)
` Loop around all spaces around this hill
for subX = x-size to x+size
for subZ = z-size to z+size
` Find dist from center of hill
dist# = Dist2(subX, subZ, x, z)
` Determine height based on distance from center and max height
h# = maxH# - ((dist#/size)*maxH#)
h# = Max(h#, 0.0)
` Determine which cell this point falls on the matrix
` (Wrap it around the edges to create a seamless matrix)
cellX = WrapX(subX) : cellZ = WrapZ(subZ)
` Average the height to surrounding squares if this space is in
` the village (Create a mostly flat area for the houses)
if z < 6 then h# = h# / 5.0
`if z < 10 then h# = h# / 2.0
` Update this tile on the matrix
inc matrixHeight#(cellX, cellZ), h#
next subZ
next subX
next i
return
` Generate the actual matrix
MakeMatrix:
` Create a large matrix
make matrix 1, matrixSize*40, matrixSize*40, matrixSize, matrixSize
` Texture matrix
prepare matrix texture 1, worldSnowImg, 1, 1
` Update matrix
update matrix 1
return
` Update the physical matrix with the points stored in our array
MatrixHeights:
` Position each matrix tile to the correct height
for x = 0 to matrixSize
for z = 0 to matrixSize
set matrix height 1, x, z, matrixHeight#(x, z)
next z
next x
` Update matrix
update matrix 1
return
` Add lighting and shadows to the physical matrix
MatrixNormals:
` Light each tile based on whether it lies in shadow or not
for x = 0 to matrixSize
for z = 0 to matrixSize
h1# = get matrix height(1, x, z)
h2# = get matrix height(1, WrapX(x+1), WrapZ(z+1))
n# = ((h1#/10.0) - (h2#/10.0)+0.5)
set matrix normal 1, x, z, n#, n#, n#
next z
next x
` Update the matrix
update matrix 1
return
` Wrap the given cell positions so they fall on the matrix somewhere
function WrapX(cellX)
if cellX < 0 then inc cellX, matrixSize+1
if cellX > matrixSize then dec cellX, matrixSize+1
endfunction cellX
function WrapZ(cellZ)
if cellZ < 0 then inc cellZ, matrixSize+1
if cellZ > matrixSize then dec cellZ, matrixSize+1
endfunction cellZ
` Scroll the matrix with the camera to create an infinite landscape
WrapMatrix:
` Check if the camera has moved enough distance to the right
if (matrix.x + (matrixSize*20)) - cam.x < 40.0
` Scroll the matrix
inc matrix.x, 40
`for i = 1 to 5 : shift matrix left 1 : next i
shift matrix left 1
` Update matrix
position matrix 1, matrix.x, 0, matrix.z
update matrix 1
endif
return
` **********************************
` ********* Media Creation *********
` **********************************
` **********************
` *** World Textures ***
` **********************
MakeWorldTextures:
` ** Snow Texture **
randomize 1000
create bitmap 1, 64, 64
` White background
ink rgb(255, 255, 255), 0
box 0, 0, 64, 64
` Add some random blue
` (Random position, size, and hue)
for i = 1 to 1500
x = rnd(64) : y = rnd(64) : size = rnd(3)+1
blue = rnd(100)
ink rgb(255-blue, 255-blue, 255), 0
box x, y, x+size, y+size
box x-64, y, x-64+size, y+size
box x, y-64, x+size, y-64+size
box x-64, y-64, x-64+size, y-64+size
next i
` Grab the image
worldSnowImg = FreeImage()
get image worldSnowImg, 0, 0, 64, 64
delete bitmap 1
` The snow image is not seamless, meaning it will not tile well on the matrix
` Paste four copies of the bitmap into a larger canvas, then blur them together.
` Then grab the center of the canvas to create a seamless, random texture
` (It still won't be perfect, but at least it will not have ugly seams)
create bitmap 1, 128, 128
paste image worldSnowImg, 0, 0 : paste image worldSnowImg, 64, 0 : paste image worldSnowImg, 0, 64 : paste image worldSnowImg, 64, 64
delete image worldSnowImg
blur bitmap 1, 6
` Store the final image
get image worldSnowImg, 32, 32, 96, 96
delete bitmap 1
` ** Starry Sky Texture **
create bitmap 1, 256, 256
` Black background
ink 0, 0
box 0, 0, 256, 256
` Add some randomly-placed stars
for i = 1 to 500
` Determine a random colour (stars are not 100% white)
r = 255-rnd(64) : g = 255-rnd(64) : b = 255-rnd(32)
` Determine a random star size
star = rnd(1)+1
` Determine random position
x = rnd(256) : y = rnd(256)
` Glow around center (large)
if star > 1 then ink rgb(r/6, g/6, b/6), 0 : box x-1, y-1, x+1, y+1
` Draw a dot for the star's center (small and large)
dot x, y, rgb(r, g, b)
next i
` Store the image
worldSkyImg = FreeImage()
get image worldSkyImg, 0, 0, 256, 256
delete bitmap 1
return
` **********************
` *** House Creation ***
` **********************
` Build a house object
function BuildHouse1()
` Find object index that house will use
obj = FreeObject()
` ** House Root **
` Make polygon and hide it
make object triangle obj, 0, 0, 0, 0, 0, 0, 0, 0, 0
hide limb obj, houseRoot
` ** Prepare to add limbs **
temp = FreeObject()
mesh = FreeMesh()
` ** Front Wall **
` Make wall
make object plain temp, 80, 40, 1
rotate object temp, 0, 0, 0
` Push to the front
offset limb temp, 0, 0, 20, -20
` Add limb
make mesh from object mesh, temp
add limb obj, houseFront, mesh
link limb obj, houseRoot, houseFront
` Cleanup
delete object temp
delete mesh mesh
` ** Left Wall **
` Make wall
make object plain temp, 40, 40, 1
rotate object temp, 0, 90, 0
` Push to the left
offset limb temp, 0, 0, 20, -40
` Add limb
make mesh from object mesh, temp
add limb obj, houseLeft, mesh
link limb obj, houseRoot, houseLeft
` Cleanup
delete object temp
delete mesh mesh
` ** Right Wall **
` Make wall
make object plain temp, 40, 40, 1
rotate object temp, 0, 270, 0
` Push to the right
offset limb temp, 0, 0, 20, -40
` Add limb
make mesh from object mesh, temp
add limb obj, houseRight, mesh
link limb obj, houseRoot, houseRight
` Cleanup
delete object temp
delete mesh mesh
` ** Front Roof **
` Make wall
make object plain temp, 90, 40, 1
rotate object temp, 45, 0, 0
` Push to the top
offset limb temp, 0, 0, 22.5, -42.5
` Add limb
make mesh from object mesh, temp
add limb obj, houseRoofF, mesh
link limb obj, houseRoot, houseRoofF
` Cleanup
delete object temp
delete mesh mesh
` ** Back Roof **
` Make wall
make object plain temp, 90, 40, 1
rotate object temp, 45, 180, 0
` Push to the top
offset limb temp, 0, 0, 22.5, -42.5
` Add limb
make mesh from object mesh, temp
add limb obj, houseRoofB, mesh
link limb obj, houseRoot, houseRoofB
` Cleanup
delete object temp
delete mesh mesh
` ** Left Attic Wall **
` Make wall
make object triangle temp, 0, 20, 0, -20, 0, 0, 20, 0, 0
rotate object temp, 0, 270, 0
` Push to the left
offset limb temp, 0, 0, 40, 40
` Add limb
make mesh from object mesh, temp
add limb obj, houseRoofL, mesh
link limb obj, houseRoot, houseRoofL
` Cleanup
delete object temp
delete mesh mesh
` ** Right Attic Wall **
` Make wall
make object triangle temp, 0, 20, 0, -20, 0, 0, 20, 0, 0
rotate object temp, 0, 90, 0
` Push to the right
offset limb temp, 0, 0, 40, 40
` Add limb
make mesh from object mesh, temp
add limb obj, houseRoofR, mesh
link limb obj, houseRoot, houseRoofR
` Cleanup
delete object temp
delete mesh mesh
` ** Window light **
` Make plain
make object plain temp, 75, 35, 1
rotate object temp, 0, 0, 0
` Push to the front
offset limb temp, 0, 0, 20, -18
` Add limb
make mesh from object mesh, temp
add limb obj, houseLight, mesh
link limb obj, houseRoot, houseLight
` Cleanup
delete object temp
delete mesh mesh
` ** Textures **
texture limb obj, houseFront, houseFrontImg
texture limb obj, houseLeft, houseSideImg
texture limb obj, houseRight, houseSideImg
texture limb obj, houseRoofF, houseRoofImg
texture limb obj, houseRoofB, houseRoofImg
texture limb obj, houseRoofL, houseAtticImg
texture limb obj, houseRoofR, houseAtticImg
texture limb obj, houseLight, houseLightOnImg
` ** Object Settings **
` Turn off culling
set object cull obj, 0
` Turn on transparency (show the light object through the windows)
set object transparency obj, 4
endfunction obj
` Generate the textures to use for houses
MakeHouseTextures:
` ** House Front Texture **
create bitmap 1, 400, 200
` Brown-red background
ink rgb(130, 30, 0), 0
box 0, 0, 400, 200
` Board outlines
ink rgb(90, 50, 40), 0
for y = 1 to 10
box 0, y*20, 400, (y*20)+3
next y
` Door
ink rgb(100, 40, 0), 0
box 155, 50, 235, 200
` Door frame
ink 0, 0
box 150, 50, 155, 200
box 235, 50, 240, 200
box 150, 45, 240, 50
` Door knob
box 200, 115, 220, 135
` Windows
ink rgb(255, 0, 255), 0
box 50, 50, 100, 150
box 290, 50, 340, 150
` Window frame (left)
ink 0, 0
box 45, 50, 50, 150
box 100, 50, 105, 150
box 45, 45, 105, 50
box 45, 150, 105, 155
box 45, 100, 105, 105
box 73, 50, 77, 150
` Window frame (right)
ink 0, 0
box 285, 50, 290, 150
box 340, 50, 345, 150
box 285, 45, 345, 50
box 285, 150, 345, 155
box 285, 100, 345, 105
box 313, 50, 317, 150
` Add some snow up against the bottom edge
ink rgb(255, 255, 255), 0
for x = 0 to 400
y = (sin(x*6.3)*5)+190
line x, y, x, 200
next x
` Store image
houseFrontImg = FreeImage()
get image houseFrontImg, 0, 0, 400, 200
delete bitmap 1
` ** House Side Texture **
create bitmap 1, 200, 200
` Brown-red background
ink rgb(130, 30, 0), 0
box 0, 0, 200, 200
` Board outlines
ink rgb(90, 50, 40), 0
for y = 1 to 10
box 0, y*20, 200, (y*20)+3
next y
` Add some snow up against the bottom edge
ink rgb(255, 255, 255), 0
for x = 0 to 450
y = (sin(x*6.3)*5)+190
line x, y, x, 200
next x
` Store image
houseSideImg = FreeImage()
get image houseSideImg, 0, 0, 200, 200
delete bitmap 1
` ** House Attic Texture **
create bitmap 1, 2, 2
` Brown-red background
ink rgb(130, 30, 0), 0
box 0, 0, 2, 2
` Store image
houseAtticImg = FreeImage()
get image houseAtticImg, 0, 0, 2, 2
delete bitmap 1
` ** House Roof Texture **
create bitmap 1, 450, 200
` Brown background
ink rgb(100, 40, 0), 0
box 0, 0, 450, 200
` Add some snow blotches
ink rgb(255, 255, 255), 0
for i = 1 to 5000
x = rnd(450) : y = rnd(200) : size = rnd(3)+1
box x, y, x+size, y+size
next i
`blur bitmap 1, 6
` Store image
houseRoofImg = FreeImage()
get image houseRoofImg, 0, 0, 450, 200
delete bitmap 1
` ** House Light-On Texture **
create bitmap 1, 2, 2
` Yellow background
ink rgb(255, 255, 0), 0
box 0, 0, 2, 2
` Store image
houseLightOnImg = FreeImage()
get image houseLightOnImg, 0, 0, 2, 2
delete bitmap 1
return
` Constants storing limb indexes for house
#constant houseRoot 0
#constant houseFront 1
#constant houseLeft 2
#constant houseRight 3
#constant houseRoofF 4
#constant houseRoofB 5
#constant houseRoofL 6
#constant houseRoofR 7
#constant houseLight 8
` *************************
` *** Reindeer Creation ***
` *************************
` Build the player reindeer object
function BuildReindeer()
` Find object index that deer will use
obj = FreeObject()
` ** Reindeer Root **
` Make polygon and hide it
make object triangle obj, 0, 0, 0, 0, 0, 0, 0, 0, 0
hide limb obj, deerRoot
` ** Prepare to add limbs **
temp = FreeObject()
mesh = FreeMesh()
` ** Reindeer Body **
` Make cylinder
make object cylinder temp, 9
rotate object temp, 0, 0, 90
scale object temp, 100, 200, 100
` Add limb
make mesh from object mesh, temp
add limb obj, deerBody, mesh
link limb obj, deerRoot, deerBody
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Back **
` Make sphere
make object sphere temp, 9, 10, 10
scale object temp, 50, 100, 100
` Push to the back
offset limb temp, 0, -18, 0, 0
` Add limb
make mesh from object mesh, temp
add limb obj, deerBack, mesh
link limb obj, deerBody, deerBack
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Tail **
` Make sphere
make object sphere temp, 4, 10, 10
scale object temp, 200, 100, 150
rotate object temp, 0, 0, 325
` Push to the back
offset limb temp, 0, -5.5, -5, 0
` Add limb
make mesh from object mesh, temp
add limb obj, deerTail, mesh
link limb obj, deerBack, deerTail
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Front **
` Make sphere
make object sphere temp, 9, 10, 10
` Push to the front
offset limb temp, 0, 9, 0, 0
` Add limb
make mesh from object mesh, temp
add limb obj, deerFront, mesh
link limb obj, deerBody, deerFront
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Neck **
` Make cone
make object cone temp, 8
rotate object temp, 0, 0, 335
scale object temp, 100, 200, 100
` Push to the front
offset limb temp, 0, 8, 5, 0
` Add limb
make mesh from object mesh, temp
add limb obj, deerNeck, mesh
link limb obj, deerFront, deerNeck
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Head **
` Make sphere
make object sphere temp, 5
rotate object temp, 0, 0, 335
scale object temp, 200, 100, 100
` Push to the top of the neck
offset limb temp, 0, 5, 15, 0
` Add limb
make mesh from object mesh, temp
add limb obj, deerHead, mesh
link limb obj, deerNeck, deerHead
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Nose **
` Make sphere
make object sphere temp, 2, 5, 5
` Push to the front of the head
offset limb temp, 0, 20.2, 7, 0
` Add limb
make mesh from object mesh, temp
add limb obj, deerNose, mesh
link limb obj, deerHead, deerNose
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Antler (Left) **
` (LOWER)
` Make cylinder
make object cylinder temp, 0.7
scale object temp, 100, 500, 100
rotate object temp, 0, 0, 35
` Push to the top of the head
offset limb temp, 0, 16, 0.8, -4.1
` Add limb
make mesh from object mesh, temp
add limb obj, deerAntlerL1, mesh
link limb obj, deerHead, deerAntlerL1
` Cleanup
delete object temp
delete mesh mesh
` (MIDDLE)
` Make cylinder
make object cylinder temp, 0.7
scale object temp, 100, 500, 100
rotate object temp, 0, 0, 335
` Push to the top of the head
offset limb temp, 0, 4, 3.6, -4.1
` Add limb
make mesh from object mesh, temp
add limb obj, deerAntlerL2, mesh
link limb obj, deerAntlerL1, deerAntlerL2
` Cleanup
delete object temp
delete mesh mesh
` (UPPER)
` Make cylinder
make object cylinder temp, 0.7
scale object temp, 100, 500, 100
rotate object temp, 0, 0, 300
` Push to the top of the head
offset limb temp, 0, -7.3, 3.85, -4.1
` Add limb
make mesh from object mesh, temp
add limb obj, deerAntlerL3, mesh
link limb obj, deerAntlerL2, deerAntlerL3
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Antler (Right) **
` (LOWER)
` Make cylinder
make object cylinder temp, 0.7
scale object temp, 100, 500, 100
rotate object temp, 0, 0, 35
` Push to the top of the head
offset limb temp, 0, 16, 0.8, 4.1
` Add limb
make mesh from object mesh, temp
add limb obj, deerAntlerR1, mesh
link limb obj, deerHead, deerAntlerR1
` Cleanup
delete object temp
delete mesh mesh
` (MIDDE)
` Make cylinder
make object cylinder temp, 0.7
scale object temp, 100, 500, 100
rotate object temp, 0, 0, 335
` Push to the top of the head
offset limb temp, 0, 4, 3.6, 4.1
` Add limb
make mesh from object mesh, temp
add limb obj, deerAntlerR2, mesh
link limb obj, deerAntlerR1, deerAntlerR2
` Cleanup
delete object temp
delete mesh mesh
` (UPPER)
` Make cylinder
make object cylinder temp, 0.7
scale object temp, 100, 500, 100
rotate object temp, 0, 0, 300
` Push to the top of the head
offset limb temp, 0, -7.3, 3.85, 4.1
` Add limb
make mesh from object mesh, temp
add limb obj, deerAntlerR3, mesh
link limb obj, deerAntlerR2, deerAntlerR3
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Leg (Front-Left) **
` Make cylinder
make object cylinder temp, 2
scale object temp, 100, 700, 100
` Position limb
offset limb temp, 0, 8, -1.01, 3
` Add limb
make mesh from object mesh, temp
add limb obj, deerLegFL, mesh
link limb obj, deerBody, deerLegFL
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Leg (Front-Right) **
` Make cylinder
make object cylinder temp, 2
scale object temp, 100, 700, 100
` Position limb
offset limb temp, 0, 8, -1.01, -3
` Add limb
make mesh from object mesh, temp
add limb obj, deerLegFR, mesh
link limb obj, deerBody, deerLegFR
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Leg (Back-Left) **
` Make cylinder
make object cylinder temp, 2
scale object temp, 100, 700, 100
` Position limb
offset limb temp, 0, -8, -1.01, 3
` Add limb
make mesh from object mesh, temp
add limb obj, deerLegBL, mesh
link limb obj, deerBody, deerLegBL
` Cleanup
delete object temp
delete mesh mesh
` ** Deer Leg (Back-Right) **
` Make cylinder
make object cylinder temp, 2
scale object temp, 100, 700, 100
` Position limb
offset limb temp, 0, -8, -1.01, -3
` Add limb
make mesh from object mesh, temp
add limb obj, deerLegBR, mesh
link limb obj, deerBody, deerLegBR
` Cleanup
delete object temp
delete mesh mesh
` ** Textures **
texture limb obj, deerBody, deerFurImg
texture limb obj, deerBack, deerFurImg
texture limb obj, deerFront, deerFurImg
texture limb obj, deerTail, deerTailImg
texture limb obj, deerNeck, deerNeckImg
texture limb obj, deerHead, deerHeadImg
texture limb obj, deerNose, deerNoseImg
texture limb obj, deerAntlerL1, deerAntlerImg
texture limb obj, deerAntlerL2, deerAntlerImg
texture limb obj, deerAntlerL3, deerAntlerImg
texture limb obj, deerAntlerR1, deerAntlerImg
texture limb obj, deerAntlerR2, deerAntlerImg
texture limb obj, deerAntlerR3, deerAntlerImg
texture limb obj, deerLegFL, deerLegImg
texture limb obj, deerLegFR, deerLegImg
texture limb obj, deerLegBL, deerLegImg
texture limb obj, deerLegBR, deerLegImg
` ** Object Settings **
` Point the antlers
rotate limb obj, deerAntlerL1, 0, 335, 0
rotate limb obj, deerAntlerR1, 0, 25, 0
` Turn on transparency (for the top of deer's neck)
set object transparency obj, 4
` Turn on culling
set object cull obj, 1
endfunction obj
` Generate the textures to use for player reindeer
MakeReindeerTextures:
` ** Fur texture **
create bitmap 1, 2, 2
` Brown background
ink rgb(120, 70, 10), 0
box 0, 0, 2, 2
` Store image
deerFurImg = FreeImage()
get image deerFurImg, 0, 0, 2, 2
delete bitmap 1
` ** Tail texture **
create bitmap 1, 32, 32
` Brown background
ink rgb(120, 70, 10), 0
box 0, 0, 32, 32
` White spot underneath tail
ink rgb(255, 255, 255), 0
box 0, 20, 32, 32
` Store image
deerTailImg = FreeImage()
get image deerTailImg, 0, 0, 32, 32
delete bitmap 1
` ** Neck texture **
create bitmap 1, 32, 32
` Brown background
ink rgb(120, 70, 10), 0
box 0, 0, 32, 32
` Make the top half pink (transparent)
ink rgb(255, 0, 255), 0
box 0, 0, 32, 8
` Store image
deerNeckImg = FreeImage()
get image deerNeckImg, 0, 0, 32, 32
delete bitmap 1
` ** Head texture **
create bitmap 1, 64, 64
` Brown background
ink rgb(120, 70, 10), 0
box 0, 0, 64, 64
` Black eyes
ink 0, 0
box 0, 18, 3, 23
box 27, 18, 30, 23
` White eye highlights
dot 1, 20, rgb(255, 255, 255)
dot 28, 20, rgb(255, 255, 255)
` Store image
deerHeadImg = FreeImage()
get image deerHeadImg, 0, 0, 64, 64
delete bitmap 1
` ** Nose texture **
create bitmap 1, 2, 2
` Red background
ink rgb(255, 0, 0), 0
box 0, 0, 2, 2
` Store image
deerNoseImg = FreeImage()
get image deerNoseImg, 0, 0, 2, 2
delete bitmap 1
` ** Antler texture **
create bitmap 1, 2, 2
` Dark-gray background
ink rgb(64, 64, 64), 0
box 0, 0, 2, 2
` Store image
deerAntlerImg = FreeImage()
get image deerAntlerImg, 0, 0, 2, 2
delete bitmap 1
` ** Leg texture **
create bitmap 1, 32, 32
` Brown background
ink rgb(120, 70, 10), 0
box 0, 0, 32, 32
` Make the hoof dark-gray
ink rgb(64, 64, 64), 0
box 0, 28, 32, 32
` Store image
deerLegImg = FreeImage()
get image deerLegImg, 0, 0, 32, 32
delete bitmap 1
return
` Constants storing limb indexes for reindeer
#constant deerRoot 0
#constant deerBody 1
#constant deerBack 2
#constant deerTail 3
#constant deerFront 4
#constant deerNeck 5
#constant deerHead 6
#constant deerNose 7
#constant deerAntlerL1 8
#constant deerAntlerL2 9
#constant deerAntlerL3 10
#constant deerAntlerR1 11
#constant deerAntlerR2 12
#constant deerAntlerR3 13
#constant deerLegFL 14
#constant deerLegFR 15
#constant deerLegBL 16
#constant deerLegBR 17
` ***********************
` *** Sleigh Creation ***
` ***********************
` Build the player sleigh object
function BuildSleigh()
` Find object index that sleigh will use
obj = FreeObject()
` ** Sleigh Bottom (Root) **
` Make floor
make object plain obj, 30, 20, 1
rotate object obj, 270, 0, 0
fix object pivot obj
` Push floor down
offset limb obj, sleighBottom, 0, 0, -10
` ** Prepare to add limbs **
temp = FreeObject()
mesh = FreeMesh()
` ** Sleigh Left Side **
` Make side
make object plain temp, 30, 20, 1
rotate object temp, 270, 180, 0
fix object pivot temp
` Push to the left
offset limb temp, 0, 0, 8.9, -10
` Add limb
make mesh from object mesh, temp
add limb obj, sleighSideL, mesh
link limb obj, sleighBottom, sleighSideL
` Cleanup
delete object temp
delete mesh mesh
` ** Sleigh Right Side **
` Make side
make object plain temp, 30, 20, 1
rotate object temp, 90, 0, 0
fix object pivot temp
` Push to the right
offset limb temp, 0, 0, 8.9, -10
` Add limb
make mesh from object mesh, temp
add limb obj, sleighSideR, mesh
link limb obj, sleighBottom, sleighSideR
` Cleanup
delete object temp
delete mesh mesh
` ** Sleigh Back **
` Make back
make object plain temp, 20, 20
rotate object temp, 90, 0, 90
fix object pivot temp
` Push to the back
offset limb temp, 0, 0, 8.9, -14.9
` Add limb
make mesh from object mesh, temp
add limb obj, sleighBack, mesh
link limb obj, sleighBottom, sleighBack
` Cleanup
delete object temp
delete mesh mesh
` ** Sleigh Front **
` Make front
make object plain temp, 20, 20
rotate object temp, 90, 0, 270
fix object pivot temp
` Push to the front
offset limb temp, 0, 0, 8.9, -14.9
` Add limb
make mesh from object mesh, temp
add limb obj, sleighFront, mesh
link limb obj, sleighBottom, sleighFront
` Cleanup
delete object temp
delete mesh mesh
` ** Left Blade **
` Make blade
make object plain temp, 50, 5, 1
rotate object temp, 270, 180, 0
fix object pivot temp
` Push to the left
offset limb temp, 0, 5, -2.5, -10.1
` Add limb
make mesh from object mesh, temp
add limb obj, sleighBladeL, mesh
link limb obj, sleighBottom, sleighBladeL
` Cleanup
delete object temp
delete mesh mesh
` ** Right Blade **
` Make blade
make object plain temp, 50, 5, 1
rotate object temp, 90, 0, 0
fix object pivot temp
` Push to the right
offset limb temp, 0, -5, -2.5, -10.1
` Add limb
make mesh from object mesh, temp
add limb obj, sleighBladeR, mesh
link limb obj, sleighBottom, sleighBladeR
` Cleanup
delete object temp
delete mesh mesh
` ** Toy Sack **
` Make sack
make object sphere temp, 20, 10, 10
scale object temp, 70, 95, 120
rotate object temp, 350, 345, 0
` Push to the back and into the sleigh
offset limb temp, 0, -5, -2, 11
` Add limb
make mesh from object mesh, temp
add limb obj, sleighSack, mesh
link limb obj, sleighBottom, sleighSack
` Cleanup
delete object temp
delete mesh mesh
` ** Toy Sack Top **
` Make cone
make object cone temp, 10
scale object temp, 50, 100, 50
rotate object temp, 250, 320, 0
fix object pivot temp
` Push to the top of the sack
offset limb temp, 0, 10, -23, -7
` Add limb
make mesh from object mesh, temp
add limb obj, sleighSackTop, mesh
link limb obj, sleighSack, sleighSackTop
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Body **
` Make sphere
make object sphere temp, 17, 10, 10
` Push to the front of the sleigh
offset limb temp, 0, 6, 0, 7
` Add limb
make mesh from object mesh, temp
add limb obj, santaBody, mesh
link limb obj, sleighBottom, santaBody
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Head **
` Make sphere
make object sphere temp, 10, 10, 10
` Push to the top of Santa's body
offset limb temp, 0, 6, 0, 19
` Add limb
make mesh from object mesh, temp
add limb obj, santaHead, mesh
link limb obj, santaBody, santaHead
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Nose **
` Make sphere
make object sphere temp, 1.5, 5, 5
scale object temp, 200, 100, 100
` Push to the front of Santa's face
offset limb temp, 0, 5.5, 0, 18.5
` Add limb
make mesh from object mesh, temp
add limb obj, santaNose, mesh
link limb obj, santaHead, santaNose
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Beard **
` (SEGMENT 1)
` Make sphere
make object sphere temp, 10, 10, 10
scale object temp, 100, 130, 50
rotate object temp, 0, 30, 0
` Push to the front of Santa's head
offset limb temp, 0, 0, 0, 37.5
` Add limb
make mesh from object mesh, temp
add limb obj, santaBeard1, mesh
link limb obj, santaHead, santaBeard1
` Cleanup
delete object temp
delete mesh mesh
` (SEGMENT 2)
` Make sphere
make object sphere temp, 10, 10, 10
scale object temp, 100, 70, 40
rotate object temp, 0, 50, 0
` Push to the front of Santa's head
offset limb temp, 0, -2, 0, 45
` Add limb
make mesh from object mesh, temp
add limb obj, santaBeard2, mesh
link limb obj, santaBeard1, santaBeard2
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Hat (Fur) **
` Make sphere
make object sphere temp, 15, 5, 5
scale object temp, 100, 100, 30
rotate object temp, 0, 330, 0
` Push to the top of Santa's head
offset limb temp, 0, 15, 0, 50
` Add limb
make mesh from object mesh, temp
add limb obj, santaHatFur, mesh
link limb obj, santaHead, santaHatFur
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Hat (Main) **
` (SEGMENT 1)
` Make cone
make object cone temp, 13
rotate object temp, 90, 330, 0
` Push to the top of Santa's head
offset limb temp, 0, 15, 22, 0
` Add limb
make mesh from object mesh, temp
add limb obj, santaHat1, mesh
link limb obj, santaHatFur, santaHat1
` Cleanup
delete object temp
delete mesh mesh
` (SEGMENT 2)
` Make cone
make object cone temp, 6.7
rotate object temp, 90, 290, 0
` Push to the top of Santa's head
offset limb temp, 0, 24.8, 10, 0
` Add limb
make mesh from object mesh, temp
add limb obj, santaHat2, mesh
link limb obj, santaHat1, santaHat2
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Hat (Puff ball) **
` Make sphere
make object sphere temp, 4, 5, 5
` Push to the top of Santa's hat
offset limb temp, 0, -4.5, 0, 27.8
` Add limb
make mesh from object mesh, temp
add limb obj, santaHatTop, mesh
link limb obj, santaHat2, santaHatTop
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Hand (Left) **
` Make sphere
make object sphere temp, 3, 5, 5
` Push to the front of Santa
offset limb temp, 0, 15, -7, 12
` Add limb
make mesh from object mesh, temp
add limb obj, santaHandL, mesh
link limb obj, santaBody, santaHandL
` Cleanup
delete object temp
delete mesh mesh
` ** Santa Hand (Right) **
` Make sphere
make object sphere temp, 3, 5, 5
` Push to the front of Santa
offset limb temp, 0, 15, 7, 12
` Add limb
make mesh from object mesh, temp
add limb obj, santaHandR, mesh
link limb obj, santaBody, santaHandR
` Cleanup
delete object temp
delete mesh mesh
` ** Textures **
texture limb obj, sleighBottom, sleighFloorImg
texture limb obj, sleighSideL, sleighLeftImg
texture limb obj, sleighSideR, sleighRightImg
texture limb obj, sleighBack, sleighBackImg
texture limb obj, sleighFront, sleighFrontImg
texture limb obj, sleighBladeL, sleighBladeLImg
texture limb obj, sleighBladeR, sleighBladeRImg
texture limb obj, sleighSack, sleighSackImg
texture limb obj, sleighSackTop, sleighSackTopImg
texture limb obj, santaBody, santaBodyImg
texture limb obj, santaHead, santaHeadImg
texture limb obj, santaNose, santaNoseImg
texture limb obj, santaBeard1, santaBeardImg
texture limb obj, santaBeard2, santaBeardImg
texture limb obj, santaHatFur, santaBeardImg
texture limb obj, santaHat1, santaHalfHatImg
texture limb obj, santaHat2, santaHatImg
texture limb obj, santaHandL, santaHandImg
texture limb obj, santaHandR, santaHandImg
` ** Object Settings **
` Turn on transparency
set object transparency obj, 4
` Turn off culling
set object cull obj, 0
endfunction obj
` Generate the textures to use for player sleigh
MakeSleighTextures:
` ** Floor texture **
create bitmap 1, 2, 2
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 2, 2
` Store image
sleighFloorImg = FreeImage()
get image sleighFloorImg, 0, 0, 2, 2
delete bitmap 1
` ** Right texture **
create bitmap 1, 150, 100
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 150, 100
` Use a sine wave to add detail
for x = 0 to 150
y = (sin((x*1.7)-80)*40)+40
` Add a white stripe along the wave
ink rgb(255, 255, 255), 0
line x, y, x, y+10
line x, y+13, x, y+14
` Fill in the area above the stripe with pink (transparent)
ink rgb(255, 0, 255), 0
line x, 0, x, y
` Make the bottom edge of the sleigh rounded
y = (sin(x*1.2)*6)+95
line x, y, x, 100
next x
` Store image
sleighRightImg = FreeImage()
get image sleighRightImg, 0, 0, 150, 100
` ** Left texture **
create bitmap 2, 150, 100
` (Mirror image of right side texture)
copy bitmap 1, 2
mirror bitmap 2
set current bitmap 2
` Store image
sleighLeftImg = FreeImage()
get image sleighLeftImg, 0, 0, 150, 100
delete bitmap 2
delete bitmap 1
` ** Back texture **
create bitmap 1, 100, 100
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 100, 100
` Add a white stripe along the top
ink rgb(255, 255, 255), 0
box 0, 0, 100, 10
box 0, 13, 100, 15
` Make the bottom edge pink (transparent)
ink rgb(255, 0, 255), 0
box 0, 95, 100, 100
` Store image
sleighBackImg = FreeImage()
get image sleighBackImg, 0, 0, 100, 100
delete bitmap 1
` ** Front texture **
create bitmap 1, 100, 100
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 100, 100
` Add a white stripe along the middle
ink rgb(255, 255, 255), 0
box 0, 45, 100, 55
box 0, 57, 100, 59
` Make the top half pink (transparent)
ink rgb(255, 0, 255), 0
box 0, 0, 100, 45
` Make the bottom edge transparent
box 0, 95, 100, 100
` Store image
sleighFrontImg = FreeImage()
get image sleighFrontImg, 0, 0, 100, 100
delete bitmap 1
` ** Left blade texture **
create bitmap 1, 250, 25
` Pink (transparent) background
ink rgb(255, 0, 255), 0
box 0, 0, 250, 25
` Add track along the bottom
ink rgb(160, 160, 160), 0
box 12, 20, 212, 25
` Add front curve
for a = 90 to 270
x = (cos(a)*10)+12 : y = (sin(a)*10)+12
box x, y, x+5, y+5
next a
` Add back curve
for a = -90 to 90
x = (cos(a)*10)+205 : y = (sin(a)*10)+12
box x, y, x+5, y+5
next a
` Add vertical bars along the track
for i = 1 to 5
box i*30, 0, (i*30)+5, 25
next i
` Store image
sleighBladeLImg = FreeImage()
get image sleighBladeLImg, 0, 0, 250, 25
` ** Right blade texture **
create bitmap 2, 250, 25
` (Mirror image of left blade texture)
copy bitmap 1, 2
mirror bitmap 2
set current bitmap 2
` Store image
sleighBladeRImg = FreeImage()
get image sleighBladeRImg, 0, 0, 250, 25
delete bitmap 2
delete bitmap 1
` ** Sack texture **
create bitmap 1, 2, 2
` Gray-green background
ink rgb(80, 100, 80), 0
box 0, 0, 2, 2
` Store image
sleighSackImg = FreeImage()
get image sleighSackImg, 0, 0, 2, 2
delete bitmap 1
` ** Sack top texture **
create bitmap 1, 64, 64
` Gray-green background
ink rgb(80, 100, 80), 0
box 0, 0, 64, 64
` Make the top ribbing pink (transparent)
ink rgb(255, 0, 255), 0
for x = 0 to 64
y = (sin(x*22.5)*3)+61
line x, y, x, 64
next x
` Store image
sleighSackTopImg = FreeImage()
get image sleighSackTopImg, 0, 0, 64, 64
delete bitmap 1
` ** Santa Body texture **
create bitmap 1, 32, 32
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 32, 32
` White stripe going down front
ink rgb(255, 255, 255), 0
box 20, 13, 32, 19
` Store image
santaBodyImg = FreeImage()
get image santaBodyImg, 0, 0, 32, 32
delete bitmap 1
` ** Santa Head texture **
create bitmap 1, 64, 64
` Flesh background
ink rgb(240, 170, 150), 0
box 0, 0, 64, 64
` White hair
ink rgb(255, 255, 255), 0
box 0, 0, 32, 64
box 60, 8, 64, 56
box 56, 16, 60, 48
` White beard
box 32, 0, 44, 64
` Eyes
ink rgb(255, 255, 255), 0
box 48, 25, 51, 29
box 48, 35, 51, 39
` Eye pupils
ink 0, 0
line 49, 27, 48, 27
line 49, 36, 48, 36
` Eyebrows
ink rgb(255, 255, 255), 0
line 52, 23, 53, 28
line 52, 39, 53, 34
` Cheeks
ink rgb(250, 130, 110), 0
box 44, 18, 48, 22
box 44, 42, 48, 46
` Store image
santaHeadImg = FreeImage()
get image santaHeadImg, 0, 0, 64, 64
delete bitmap 1
` ** Santa Nose texture **
create bitmap 1, 2, 2
` Pink flesh background
ink rgb(250, 130, 110), 0
box 0, 0, 2, 2
` Store image
santaNoseImg = FreeImage()
get image santaNoseImg, 0, 0, 2, 2
delete bitmap 1
` ** Santa Beard texture **
create bitmap 1, 2, 2
` White background
ink rgb(255, 255, 255), 0
box 0, 0, 2, 2
` Store image
santaBeardImg = FreeImage()
get image santaBeardImg, 0, 0, 2, 2
delete bitmap 1
` ** Santa Half-Hat texture **
create bitmap 1, 32, 32
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 32, 32
` Make top of hat pink (transparent)
ink rgb(255, 0, 255), 0
box 0, 0, 32, 14
` Store image
santaHalfHatImg = FreeImage()
get image santaHalfHatImg, 0, 0, 32, 32
delete bitmap 1
` ** Santa Hat texture **
create bitmap 1, 2, 2
` Red background
ink rgb(200, 0, 0), 0
box 0, 0, 2, 2
` Store image
santaHatImg = FreeImage()
get image santaHatImg, 0, 0, 2, 2
delete bitmap 1
` ** Santa Glove texture **
create bitmap 1, 2, 2
` Brown background
ink rgb(64, 32, 0), 0
box 0, 0, 2, 2
` Store image
santaHandImg = FreeImage()
get image santaHandImg, 0, 0, 2, 2
delete bitmap 1
return
` Constants storing limb indexes for sleigh and Santa
#constant sleighFloor 0
#constant sleighSideL 1
#constant sleighSideR 2
#constant sleighBack 3
#constant sleighFront 4
#constant sleighBladeL 5
#constant sleighBladeR 6
#constant sleighSack 7
#constant sleighSackTop 8
#constant santaBody 9
#constant santaHead 10
#constant santaNose 11
#constant santaBeard1 12
#constant santaBeard2 13
#constant santaHatFur 14
#constant santaHat1 15
#constant santaHat2 16
#constant santaHatTop 17
#constant santaHandL 18
#constant santaHandR 19
` ***********************
` *** Misc. Functions ***
` ***********************
` Return the 2D distance between two points
function Dist2(x1#, y1#, x2#, y2#)
d# = sqrt((x2#-x1#)*(x2#-x1#) + (y2#-y1#)*(y2#-y1#))
endfunction d#
` Return the lower of two number
function Min(n1#, n2#)
if n1# > n2# then n1# = n2#
endfunction n1#
` Return the higher of two number
function Max(n1#, n2#)
if n1# < n2# then n1# = n2#
endfunction n1#
` Return the positive/negative sign of any number
function Sign(n#)
if n# < 0.0 then exitfunction -1
if n# > 0.0 then exitfunction 1
endfunction 0
` Erase all media from memory
ClearAll:
for i = 1 to 10000
if sprite exist(i) then delete sprite i
if object exist(i) then delete object i
if sound exist(i) then delete sound i
if matrix exist(i) then delete matrix i
if image exist(i) then delete image i
next i
flush video memory
return
` Find a free image index
function FreeImage()
repeat
inc n
until image exist(n) = 0
endfunction n
` Find a free object index
function FreeObject()
repeat
inc n
until object exist(n) = 0
endfunction n
` Find a free mesh index
function FreeMesh()
repeat
inc n
until mesh exist(n) = 0
endfunction n
` Find a free sprite index
function FreeSprite()
repeat
inc n
until sprite exist(n) = 0
endfunction n
Cheers!