Muziko Kreito Universo

Kevin Heis

Terminal Creative Project Documentation Presented to the University of Oregon School of Music and Dance in partial fulfillment of the requirements for the degree of Master of Music in Intermedia Music Technology June 2010

Heis, Muziko Kreito Universo: Project Documentation, 2

Muziko Kreito Universo, a project prepared by Kevin Heis in partial fulfillment of the requirements for the Master of Music degree in the School of Music and Dance. This terminal project has been approved and accepted by:

___________________________________________________________________________ Dr. Jeffrey Stolet Chair of the Examining Committee

___________________________________________________________________________ Date

Committee in Charge: Dr. Jeffrey Stolet, Chair Ying Tan Craig Hickman Robert Ponto Dr. Steve Vacchi

Accepted by:

___________________________________________________________________________ Dr. Ann B. Tedards Associate Dean and Director of Graduate Studies, School of Music and Dance

Heis, Muziko Kreito Universo: Project Documentation, 3

©2010 Kevin Heis

Heis, Muziko Kreito Universo: Project Documentation, 4

Thanks
Committee
Dr. Jeffrey Stolet, Professor of Music Technology, Advisor Professor Ying Tan, Associate Professor of Digital Art Professor Craig Hickman, Professor of Digital Art Professor Robert Ponto, Associate Professor of Conducting Dr. Steve Vacchi, Associate Professor of Bassoon

Colleagues
Jenifer Jaseau Simon Hutchinson Chi Wang Clay Kent Jon Bellona Loren Mohler Kevin Drake Tammy Coles

Technology
The Cycling '74 team The developers of Cosm at the University of California, Santa Barbara

Heis, Muziko Kreito Universo: Project Documentation, 5

Table of Contents
Abstract
Concept Technology In conjunction

6
6 6 6

Textual Description State Machine Diagram Source code
Max patches Lua source code
File: File: File: File: File: File: File: File: File: File: File: File: File: File: mku.lua universal.lua tween_delay.lua color.lua flicker.lua bolts.lua kreito.lua kreito_template.lua radiuso.lua flugilo.lua konko.lua streko.lua drivo.lua mku_c74.txt

7 11 12
13 18
18 19 22 23 24 24 25 34 35 37 40 43 45 49

Heis, Muziko Kreito Universo: Project Documentation, 6

Abstract
Concept
Muziko Kreito Universo is a three-dimensional visual and ambisonic sound installation. The work is experienced as a digital universe of intelligent musical creatures, where human participants act as gods influencing the environment as the creatures strive for auditory greatness. The work explores themes of creation and destruction, of power and servitude, and of the role of humans in an environment with other beings, as well as the fundamental relationship between the essence of sound and decision-making beings.

Technology
The primary technologies used in Muziko Kreito Universo are: 1. Max/MSP/Jitter, an audiovisual development environment; 2. OpenGL, a graphics library specification; 3. Cosm, a framework for virtual worlds in Max/MSP/JItter; 4. Lua, a powerful, beautiful, efficient scripting language; as well as a 5. SpaceNavigator, a six-degree three-dimensional mouse; and 6. c74, a customizable user interface application on the iPod Touch.

In conjunction
A video demonstration can be found at:
http://kevinheis.net/mku/

Source code is provided at the end of this document.

Heis, Muziko Kreito Universo: Project Documentation, 7

Textual Description
Muziko Kreito Universo is an original audiovisual interactive work based on concepts of artificial intelligence. Muziko Kreito Universo is a digital universe of intelligent music creatures. These musical creatures live full life cycles as they strive for auditory greatness. A human acts as a god to the musical creatures by influencing various aspects of the universe. The work is experienced as an installation: a three-dimensional visual and ambisonic universe. Muziko Kreito Universo works with ideas of creation and destruction, power and servitude, the role of humans in an environment with other beings, and the fundamental essence of sound to decision-making beings. The audiovisual interactive work is inspired by video games, real world animals, and scholarly and artistic works. Some of the influential video games include Flow, The Sims, Osmos, Elektroplankton, Spore, and Black and White. The models and animations of the creatures are based on deep sea creatures, as seen in Planet Earth and The Deep. Some of the scholarly influences include Visual Space Music by mememamo, Marc Downie's work on intelligent music characters at MIT, and works using the Cosm framework from UC, Santa Barbara. Muziko Kreito Universo is built out of a combination of software and human user interaction technologies. The software used is Max/MSP/Jitter, an audiovisual development environment, Cosm, a framework for building virtual worlds in Max/MSP/Jitter, the Lua scripting language, and OpenGL. The user interaction devices are a SpaceNavigator, a sixdegree, three-dimensional mouse, and an iPod Touch running the c74 application.

Heis, Muziko Kreito Universo: Project Documentation, 8

The creatures in the Muziko Kreito Universo environment are driven by state machines. A state machine is a model used by computer programmers to create agents. An agent is an entity that makes decisions. Each creature has a state machine. The state machine is comprised of a set of states. For each state machine in the Muziko Kreito Universo environment, only one state can be active at a time. Within each state there exists a set of behaviors. These behaviors include embedded rules that can cause the active state to change to a different state. Each creature has three attributes with which to guide decision-making. The three attributes are age, health, and energy. At any point in time, each creature is in one of twelve creature states, which are birth, follow parent, wander, sleep, pursue, play, procreate, hunt, fight, chase, flee, and death. The three kinds of creature relationships, parent and children, playmates, and prey and predator, have been formulated in this world. The creatures move in space by use of steering forces. A steering force is an algorithm for determining paths for autonomous agents using vector mathematics. Muziko Kreito Universo's creatures are represented in the universe both visually and sonically. The sound system is rendered in real time in ambisonics, an audio methodology for encoding and decoding multiple audio channels to create a realistic spatialization of sound producing objects. The ambisonic system uses panning, volume, low-pass filtering, reverberation, and pitch to spatialize sound producing objects. Each creature type has a set of sound samples associated with it that change over time. These samples are played back with changes in rhythm, pitch, volume, and distortion depending on the creature's active state and attributes.

Heis, Muziko Kreito Universo: Project Documentation, 9

There are five types of creatures in Muziko Kreito Universo. These are named radiuso (jelly), flugilo (ray), konko (shelled creature), streko (eel), and drivo (drifter). These models are rendered in OpenGL using simple geometric shapes, like spheres and cones. Each of these models has a set of animations that are associated with the model. These animations are move, procreate, sleep, death, flee, and four possible play/fight animations. The animations are executed by use of tweens, an algorithm that changes a numeric variable over time. The colors and animations of the creatures represent the creature's current state. The human participant interacts with these creatures with a SpaceNavigator and an iPod Touch running the c74 application. The SpaceNavigator provides the end user the ability to move through the digital universe by rotating, pushing, and pulling on a knob that can be moved in six directions. The c74 application allows the participant to influence the creatures' health and energy globally, pause the universe, or return the position of the participant to the starting position. The influence over health and energy is represented by a heads-up style display, with colors to represent the strength and type of influence the participant has over the creatures. The primary challenges of creating Muziko Kreito Universo were the issue of playing god, the challenge of multiplicity, and working in three visual and sonic dimensions. The question of playing god is a natural part of creating an artificial intelligent system, and provokes questions such as 'What is the effect of a god?' The system has been designed to answer these questions as directly as possible. The challenge of multiplicity is both conceptual and technological. With up to thirty-two creatures in the space, the creatures

Heis, Muziko Kreito Universo: Project Documentation, 10

needed to be simple and obvious in their actions. Finally, the three-dimensional challenges were solved using a combination of audiovisual and interactive technologies. The work will be installed on Monday, April 19th from 8:30am to 12:30pm in the University of Oregon School of Music in room 140; Friday, April 30th from 10am to 3pm in the University of Oregon Erb Memorial Union in the concourse; Saturday, May 1st from 6pm to 10pm in the University of Oregon School of Music in room 140 as part of the [m] event; and performed on Saturday, May 8th at the Future Music Oregon concert at 8pm.

Heis, Muziko Kreito Universo: Project Documentation, 11

State Machine Diagram
BIRTH

PLAY

FOLLOW PARENT

PURSUE

WANDER

SLEEP

PROCREATE

HUNT

[provoked]

FIGHT

FLEE

CHASE

DEATH

Heis, Muziko Kreito Universo: Project Documentation, 12

Source code
The source code of this document is divided into two sections: Max patches, and Lua source code.

Heis, Muziko Kreito Universo: Project Documentation, 13

Max patches

Heis, Muziko Kreito Universo: Project Documentation, 14

Heis, Muziko Kreito Universo: Project Documentation, 15

Heis, Muziko Kreito Universo: Project Documentation, 16

Heis, Muziko Kreito Universo: Project Documentation, 17

Heis, Muziko Kreito Universo: Project Documentation, 18

Lua source code
File: mku.lua
function msg_float (i) ! u.time_elapse = i ! if u.is_running == 1 then ! ! u.sketch:reset() ! ! u.time = u.time + u.time_elapse ! ! u.global_age = u.life_rate * u.time_elapse ! ! u.count_kreitoj() ! ! flicker:update() ! ! for i in pairs(u.kreitoj) do ! ! ! if u.kreitoj[i] ~= nil then ! ! ! ! u.kreitoj[i]:update() ! ! ! end ! ! end ! ! u.bolts:draw() ! end ! u.update_resetter() ! u.send("time_elapse", u.time_elapse) end function scale (i) ! u.scale(i) end function control_data (health, energy) ! u.control_data (health, energy) end function k_message (callername, element, ...) ! if u.kreitoj[callername] ~= nil then ! ! if element == "position" then ! ! ! u.kreitoj[callername].position_x = arg[1] ! ! ! u.kreitoj[callername].position_y = arg[2] ! ! ! u.kreitoj[callername].position_z = arg[3] ! ! elseif element == "rotate" then ! ! ! u.kreitoj[callername].rotate_r = arg[1] ! ! ! u.kreitoj[callername].rotate_x = arg[2] ! ! ! u.kreitoj[callername].rotate_y = arg[3] ! ! ! u.kreitoj[callername].rotate_z = arg[4] ! ! end ! end end function sound_path (path) ! flicker.localpath = path end function is_running (toggle) ! u.is_running = toggle end function reset_elapse () ! u.interact_elapse = 0 end function master_position (x, y, z, a, b, c) ! u.masterx = x ! u.mastery = y ! u.masterz = z ! u.lookatx = a ! u.lookaty = b ! u.lookatz = c end importfile('universal.lua') importfile('flicker.lua') importfile('color.lua') importfile('tween_delay.lua') importfile('bolts.lua')

Heis, Muziko Kreito Universo: Project Documentation, 19

importfile('kreito.lua') importfile('radiuso.lua') importfile('flugilo.lua') importfile('konko.lua') importfile('streko.lua') importfile('drivo.lua')

File: universal.lua
u = {} u.time = 0 u.time_elapse = 0 u.interact_elapse = 0 u.global_health = 0 u.global_energy = 0 u.global_age = 0 u.is_running = 1 u.life_rate = 0.0000024 --life is approximately 4 minutes long u.slow_rate = 0.000012 u.mid_rate = 0.000024 u.fast_rate = 0.000048 u.stop_rate = 0 u.walk_rate = 0.004 u.run_rate = 0.012 u.pitch_rate = u.mid_rate * 240 u.time_range = 2500 u.lumo_hue = 0 u.lumo_saturation = 0 u.specular_intensity = 0 u.kreitoj = {} u.kreitoj_count = {} u.age_to_octave = {4, 2, 1, 1/2, 1/4, 1/8, 1/8, 1/8, 1/8, 1/8} u.kreito_types = {"radiuso", "flugilo", "konko", "streko", "drivo"} u.desired_radius = 1 u.slices = 10 u.loc = "" u.h_pi = math.pi / 2 u.sketch = jit.new("jit.gl.sketch", this.drawto) u.sketch:reset() u.sketch.smooth_shading = 1 u.sketch.lighting_enable = 1 u.sketch.blend_enable = 1 u.sketch.auto_material = 0 u.sketch.shininess = 50 u.sketch.blend_mode = {6, 1} u.sketch:glmatrixmode("modelview") u.sketch.enable = 1 u.sketch.depth_clear = 1 u.sketch.depth_enable = 1 u.sketch.layer = 9999 u.masterx = 0 u.mastery = 0 u.masterz = 0 u.lookatx = 0 u.lookaty = 0 u.lookatz = 0 function u.createClass (...) ! local function search (k, plist) ! ! for i=1, table.getn(plist) do ! ! ! local v = plist[i][k] ! ! ! if v then return v end ! ! end ! end ! local c = {}

Heis, Muziko Kreito Universo: Project Documentation, 20

! setmetatable(c, {__index = function (t, k) return search(k, arg) end}) ! c.__index = c ! function c:new (o) ! ! o = o or {} ! ! setmetatable(o, c) ! ! return o ! end ! return c end function u.remove (arr, element) ! for i,v in ipairs(arr) do ! ! if v == element then ! ! ! table.remove(arr, i) ! ! ! break ! ! end ! end end function u.scale (i) ! u.max_kreitoj = 16 * i ! u.world_size = 4 * u.max_kreitoj ! u.orb_size = math.ceil(math.sqrt(2 * (u.world_size)^2)) * 6/5 ! u.send("world_size", u.world_size) ! u.send("orb_size", u.orb_size) ! u.send("max_kreitoj", u.max_kreitoj) end function u.send (location, ...) ! if location ~= u.loc then ! ! outlet(0, "send", location) ! end ! outlet(0, ...) end function u.control_data (h, e) ! --lazy color object creation ! if u.lumo_color == nil then ! ! u.lumo_color = color:new() ! end ! --Get 0 to 1 values into -1 to 1 ! local health = h * 2 - 1 ! local energy = e * 2 - 1 ! --Get the intensity of the overall effect ! local intensity = math.abs(health) + math.abs(energy) ! local percent_health = math.abs(health) / intensity ! local percent_energy = math.abs(energy) / intensity ! if intensity > 1 then intensity = 1 end ! u.specular_intensity = intensity + 1 ! u.lumo_saturation = intensity ! flicker.rate = (1 - intensity) * 29500 + 500 ! u.lumo_light = 1/4 ! --Set the global effects ! u.global_health = health * u.fast_rate * 10 ! u.global_energy = energy * u.fast_rate * 10 ! --Figure out the hue via weighted average ! local par_h = 0 ! local par_e = 0 ! if health > 0 then ! ! par_h = percent_health * 1/2 ! elseif health < 0 then ! ! par_h = percent_health * 1 ! end ! if energy > 0 and health > 0 then ! ! par_e = percent_energy * 1/4 ! elseif energy > 0 then ! ! par_e = percent_energy * 5/4 ! elseif energy < 0 then ! ! par_e = percent_energy * 3/4

Heis, Muziko Kreito Universo: Project Documentation, 21

! end ! u.lumo_hue = par_h + par_e ! --Calculate color and send it out ! u.lumo_color:hsl2rgb(u.lumo_hue, u.lumo_saturation, u.lumo_light) ! u.send("intensity", intensity) ! u.send("lighting", "light_diffuse", u.lumo_color.r, u.lumo_color.g, u.lumo_color.b) ! u.send("lighting", "light_specular", u.specular_intensity, u.specular_intensity, ! ! u.specular_intensity) ! u.send("lumo_color", "color", u.lumo_color.r, u.lumo_color.g, u.lumo_color.b, ! ! u.lumo_saturation) end function u.count_kreitoj () ! --set the count for all types to zero ! for j in ipairs(u.kreito_types) do ! ! u.kreitoj_count[u.kreito_types[j]] = 0 ! end ! --add each kreito to its faction's count ! for j in pairs(u.kreitoj) do ! ! for k in ipairs(u.kreito_types) do ! ! ! if u.kreitoj[j].kreito_type == u.kreito_types[k] then ! ! ! ! local m = u.kreitoj_count[u.kreito_types[k]] ! ! ! ! u.kreitoj_count[u.kreito_types[k]] = m + 1 ! ! ! end ! ! end ! end ! --if a faction has no member, make one ! for j in ipairs(u.kreito_types) do ! ! if u.kreitoj_count[u.kreito_types[j]] == 0 then ! ! ! u.genesis(u.kreito_types[j]) ! ! end ! end end function u.ra() ! return (math.random() * u.world_size * 2 - u.world_size) * 9/10 end function u.genesis (kind) ! --find an empty slot ! local childnum = nil ! for i = 1, u.max_kreitoj do ! ! if u.kreitoj[i] == nil then ! ! ! childnum = i ! ! ! break ! ! end ! end ! --make a kreito of the correct kind in the empty slot ! if childnum ~= nil then ! ! u.kreitoj[childnum] = u[kind]:new() ! ! local c = u.kreitoj[childnum] ! ! c:setup() ! ! c.name = childnum ! ! c:set_position{u.ra(), u.ra(), u.ra()} ! ! c:set_rotate{90, u.ra(), u.ra(), u.ra()} ! ! c:add_tween{0, 1, 2000, 'linear', 'alpha'} ! end end function u.update_resetter () ! u.interact_elapse = u.interact_elapse + u.time_elapse ! if u.interact_elapse > 20000 then ! ! u.send("reset_controls", 'bang') ! ! u.interact_elapse = 0 ! end ! u.send("time_elapse", u.time_elapse) end u.color_table = { ! birth = 0,

Heis, Muziko Kreito Universo: Project Documentation, 22

! follow_parent = 60/360, ! wander = 180/360, ! sleep = 240/360, ! pursue = 150/360, ! play = 120/360, ! procreate = 300/360, ! hunt = 20/360, ! fight = 0, ! chase = 0, ! flee = 270/360, ! death = 0 } u.volume_table = { ! birth = 1/2, ! follow_parent = 1/3, ! wander = 1/3, ! sleep = 1/10, ! pursue = 1/2, ! play = 1, ! procreate = 1, ! hunt = 1/2, ! fight = 1, ! chase = 2/3, ! flee = 1/2, ! death = 1/2 }

File: tween_delay.lua
--tween tween = {} function tween:set ( t ) ! --[[ ! t[1] = begin (int) ! t[2] = end (int) ! t[3] = duration (int) ! t[4] = tween type (string) ! t[5] = super's property (string) ! t[6] = super's final function (string) ! ]]-! self.begin = t[1] ! self.change = t[2] - t[1] ! self.duration = t[3] ! self.tween_type = t[4] ! self.property = t[5] ! self.final_function = t[6] ! self.start_time = u.time end function tween:update () ! if u.time - self.start_time > self.duration then ! ! if self.final_function ~= nil then ! ! ! self.super[self.final_function](self.super) ! ! end ! ! u.remove(self.super.tweens, self) ! else self[self.tween_type](self) ! end end function tween:linear () ! self.super[self.property] = self.change * (u.time - self.start_time) / ! ! self.duration + self.begin end function tween:sine () ! self.super[self.property] = self.change / 2 * (1 - math.cos(math.pi * (u.time ! ! - self.start_time) / self.duration)) + self.begin end

Heis, Muziko Kreito Universo: Project Documentation, 23

u.tween = u.createClass(tween) --delay delay = {} function delay:set (t) ! --[[ ! t[1] = duration (int) ! t[2] = function (string) ! ]]-! self.start_time = u.time ! self.duration = t[1] ! self.func = t[2] end function delay:update () ! if u.time - self.start_time > self.duration then ! ! self.super[self.func](self.super) ! ! u.remove(self.super.delays, self) ! end end u.delay = u.createClass(delay)

File: color.lua
color = {} color.r = 0 color.g = 0 color.b = 0 function color:hsl2rgb (h, s, l) ! if s == 0 then ! ! self.r = l ! ! self.g = l ! ! self.b = l ! else ! ! local q ! ! if l < 1/2 then ! ! ! q = l * (1 + s) ! ! else ! ! ! q = l + s - l * s ! ! end ! ! local p = 2 * l - q ! ! self.r = self:hue2rgb (p, q, h + 1/3) ! ! self.g = self:hue2rgb (p, q, h) ! ! self.b = self:hue2rgb (p, q, h - 1/3) ! end end function color:hue2rgb (p, q, t) ! while t < 0 do t = t + 1 end ! while t > 1 do t = t - 1 end ! if t < 1/6 then ! ! return p + (q - p) * 6 * t ! elseif t < 1/2 then ! ! return q ! elseif t < 2/3 then ! ! return p + (q - p) * (2/3 - t) * 6 ! else ! ! return p ! end end color = u.createClass(color)

Heis, Muziko Kreito Universo: Project Documentation, 24

File: flicker.lua
flicker = {} flicker.rate = 30000 flicker.time = 0 flicker.count = 1 flicker.folders = 10 flicker.set = math.ceil(math.random() * flicker.folders) flicker.localpath = nil function flicker:update () ! self.time = self.time + u.time_elapse ! if self.time > self.rate then ! ! self:flick() ! end end flicker.toAl = { 'a', 'b', 'c', 'd', 'e', 'f' } function flicker:flick () ! if self.count > #u.kreito_types then ! ! self.count = 1 ! ! self.set = math.ceil(math.random() * self.folders) ! end ! if self.localpath ~= nil then ! ! local p = self.localpath.."/"..self.set.."/"..flicker.toAl[self.count]..".aiff" ! ! u.send("buf_"..u.kreito_types[self.count], "read", p) ! end ! self.time = 0 ! self.count = self.count + 1 end

File: bolts.lua
u.bolts = {} function u.bolts:draw () ! local kposx ! local kposy ! local kposz ! local ox = u.bolts.x ! local oy = u.bolts.y ! local oz = u.bolts.z ! u.bolts.x = (u.masterx - 4 * (u.lookatx - u.masterx) + ox ) / 2 ! u.bolts.y = (u.mastery - 4 * (u.lookaty - u.mastery) + oy ) / 2 ! u.bolts.z = (u.masterz - 4 * (u.lookatz - u.masterz) + oz ) / 2 ! local constant = u.lumo_saturation * .01 ! u.sketch:glpushmatrix() ! u.sketch:glcolor(u.lumo_color.r, u.lumo_color.g, u.lumo_color.b, u.lumo_saturation * ! ! math.random() / 2) ! for i in pairs(u.kreitoj) do ! ! if u.kreitoj[i] ~= nil then ! ! ! kposx = u.kreitoj[i].position_x ! ! ! kposy = u.kreitoj[i].position_y ! ! ! kposz = u.kreitoj[i].position_z ! ! ! u.sketch:glbegin("tri_strip") ! ! ! u.sketch:glvertex(u.bolts.x, u.bolts.y+constant, u.bolts.z) ! ! ! u.sketch:glvertex(u.bolts.x, u.bolts.y-constant, u.bolts.z) ! ! ! u.sketch:glvertex(kposx, kposy, kposz) ! ! ! u.sketch:glend() ! ! end ! end ! u.sketch:glpopmatrix() end u.bolts.x = 0 u.bolts.y = 0 u.bolts.z = -100

Heis, Muziko Kreito Universo: Project Documentation, 25

File: kreito.lua
kreito = {} function kreito:setup () ! --movement parameters ! self.mvmt_hault = 2 ! self.mvmt_ease = 7 ! self.check_dist = 1 ! self.azimuth = 0 ! self.elevation = 0 ! self.delta_azimuth = 0 ! self.delta_elevation = 0 ! self.magnitude = 0 ! self.max_speed = 0 ! self.speed = 0 ! self.w_target_x = u.ra() ! self.w_target_y = u.ra() ! self.w_target_z = u.ra() ! self.position_x = 0 ! self.position_y = 0 ! self.position_z = 0 ! self.rotate_r = 0 ! self.rotate_x = 0 ! self.rotate_y = 0 ! self.rotate_z = 0 ! --ai parameters ! self.age = 0 ! self.health = 1 ! self.energy = 1 ! self.name = 0 ! self.delta_health = 0 ! self.delta_energy = 0 ! self.current_state = "birth" ! --relationship parameters ! self.prey = nil ! self.predator = nil ! self.parent_self = nil ! self.playmates = {} ! self.children_kreito = {} ! --sound parameters ! self.volume = 1/2 ! self.delta_pitch = 0 ! self.overdrive = 1 ! self.frequency = 0 ! self.lasttick = u.time ! self.millis = 0 ! self.pulse = 0 ! self.pitch = math.random() * 12 ! --tween and delay ! self.tweens = {} ! self.delays = {} ! --color variables ! self.hue = u.color_table["follow_parent"] ! self.saturation = 0 ! self.light = 1/4 ! self.alpha = 0 ! self.color = color:new() ! --faction param setup ! self:setup_faction() ! --fade in ! self:add_tween{0, 1, 2000, 'linear', 'alpha'} end --movement functions function kreito:mvmt_stop () ! self.speed = 0

Heis, Muziko Kreito Universo: Project Documentation, 26

! self.delta_azimuth = 0 ! self.delta_elevation = 0 end function kreito:set_wtarget () ! self.w_target_x = u.ra() ! self.w_target_y = u.ra() ! self.w_target_z = u.ra() end function kreito.wrap90 (n) ! while n > 45 do ! ! n = n - 45 ! end ! while n < -45 do ! ! n = n + 45 ! end ! return n end function kreito:steer (mode, target) ! --figure out the difference vector ! if mode == "flee" then ! ! self.v_x = self.position_x - target.position_x ! ! self.v_y = self.position_y - target.position_y ! ! self.v_z = self.position_z - target.position_z ! elseif mode == "wander" then ! ! self.v_x = self.w_target_x - self.position_x ! ! self.v_y = self.w_target_y - self.position_y ! ! self.v_z = self.w_target_z - self.position_z ! else ! ! self.v_x = target.position_x - self.position_x ! ! self.v_y = target.position_y - self.position_y ! ! self.v_z = target.position_z - self.position_z ! end ! --store previous values for delta calculation ! self.prev_azimuth = self.azimuth ! self.prev_elevation = self.elevation ! --get magnitude and normalize difference vector ! self.magnitude = math.sqrt((self.v_x)^2 + (self.v_y)^2 + (self.v_z)^2) ! if self.magnitude < self.mvmt_hault then ! ! self.magnitude = 0 ! ! self.azimuth = 0 ! ! self.elevation = 0 ! else ! ! self.v_x = self.v_x / self.magnitude ! ! self.v_y = self.v_y / self.magnitude ! ! self.v_z = self.v_z / self.magnitude ! ! self.azimuth = math.atan2(self.v_x, self.v_z) * 180 / math.pi ! ! self.elevation = math.acos(self.v_y) * 180 / math.pi - 90 ! end ! --calcuate change ! self.t_e = u.time_elapse / 10 ! self.delta_azimuth = self.wrap90(self.azimuth - self.prev_azimuth) * self.t_e ! self.delta_elevation = self.wrap90(self.elevation - self.prev_elevation) * self.t_e ! --add easing to speed, changes in target ! if mode == "arrive" and self.magnitude < self.mvmt_ease then ! ! self.chunk = self.magnitude / (self.mvmt_ease + self.mvmt_hault / 2) ! ! self.delta_azimuth = self.delta_azimuth * self.chunk ! ! self.delta_elevation = self.delta_elevation * self.chunk ! ! self.speed = self.max_speed * self.chunk ! elseif mode == "wander" and self.magnitude < self.mvmt_ease then ! ! self:set_wtarget() ! ! self.speed = 0 ! else ! ! self.speed = self.max_speed ! end end

Heis, Muziko Kreito Universo: Project Documentation, 27

function kreito:set_position (t) ! self.position_x = t[1] ! self.position_y = t[2] ! self.position_z = t[3] ! u.send("nav"..self.name, "position", t[1], t[2], t[3]) end function kreito:set_rotate (t) ! self.rotate_r = t[1] ! self.rotate_x = t[2] ! self.rotate_y = t[3] ! self.rotate_z = t[4] ! u.send("nav"..self.name, "rotate", t[1], t[2], t[3], t[4]) end --ai functions function kreito:update () ! self[self.current_state .. "_state"](self) ! self:ai_factors_calc() ! self:sound_param_calc() ! self:color_calc() ! if self.current_state ~= "death" then ! ! self:death_test() ! end ! self:update_tweens() ! self:update_delays() ! self:send_messages() ! self:draw() end function kreito:send_messages () ! --u.send("mon"..self.name, self.current_state, self.age, self.health, self.energy) ! u.send("audio"..self.name, self.kreito_type, self.pulse, self.volume, self.frequency, ! ! self.overdrive) ! u.send("nav"..self.name, "move", 0, 0, self.speed) ! u.send("nav"..self.name, "turn", self.delta_azimuth, self.delta_elevation, 0) ! u.send("nav"..self.name, 'bang') end function kreito:setup_sketch () ! u.sketch:gltranslate(self.position_x, self.position_y, self.position_z) ! u.sketch:glrotate(self.rotate_r, self.rotate_x, self.rotate_y, self.rotate_z) ! local scale = (2/5 + self.age * 2) * (self.pulse * self.volume + 1) ! u.sketch:glscale(scale, scale, scale) ! u.sketch:shapeslice(10) end function kreito:ai_factors_calc () ! self.age = self.age + u.global_age ! local gh = (u.global_health + self.faction_health) * u.time_elapse / 2 ! local ge = (u.global_energy + self.faction_energy) * u.time_elapse / 2 ! local decay = self.age * u.slow_rate * u.time_elapse ! --calculate health ! if self.health > 1 then ! ! self.health = 1 ! else ! ! self.health = self.health + self.delta_health + gh - decay ! end ! --calculate energy ! if self.energy > 1 then ! ! self.energy = 1 ! elseif self.energy < 0 then ! ! self.energy = 0 ! else ! ! self.energy = self.energy + self.delta_energy + ge - decay ! end end function kreito:sound_param_calc () ! --figure out overdrive ! if self.current_state == "fight" then

Heis, Muziko Kreito Universo: Project Documentation, 28

! ! self.overdrive = 10 ! elseif self.current_state == "hunt" then ! ! self.overdrive = 5 ! elseif self.current_state == "flee" then ! ! self.overdrive = 3 ! else self.overdrive = 1 ! end ! --set volume, pitch ! self.volume = (self.health * 2/3 + 1/3) * u.volume_table[self.current_state] ! self.pitch = self.pitch + self.delta_pitch ! if self.pitch < 0 then ! ! self.pitch = self.pitch + 12 ! end ! --frequency ! self.q_pitch = 2^((self.pitch % 12) / 12) ! self.q_age = math.ceil(self.age * 8) ! self.frequency = u.age_to_octave[self.q_age] * self.q_pitch ! --pulsation ! if u.time > self.millis + self.lasttick then ! ! self.pulse = 1 ! ! self.lasttick = u.time ! ! self.rate = (1 - self.age + self.energy + self.health) / 3 ! ! self.millis = (1 - self.rate) * u.time_range + 50 ! else ! ! self.pulse = 0 ! end end function kreito:color_calc () ! if self.current_state ~= "birth" and self.current_state ~= "death" then ! ! self.alpha = self.health * 2/3 +1/3 ! ! self.saturation = self.energy * 2/3 +1/3 ! else ! ! self.saturation = 0 ! end ! self.color:hsl2rgb(self.hue, self.saturation, self.light) end function kreito:change_state (a_state) ! self.current_state = a_state ! self:add_tween{self.hue, u.color_table[a_state], 500, 'linear', 'hue'} end function kreito:death_test () ! if self.health < 0 or self.age > 1 then ! ! self:anim_death() ! ! self:change_state( "death" ) ! ! self:add_tween{self.alpha, 0, 2000, 'linear', 'alpha'} ! ! self:add_delay{2000, 'terminate'} ! end end --tween and delay functions function kreito:add_tween (t) ! local tw = u.tween:new() ! tw.super = self ! tw:set(t) ! self.tweens[#self.tweens+1] = tw end function kreito:cancel_tweens () ! while self.tweens[1] do ! ! self.tweens[#self.tweens] = nil ! end end function kreito:update_tweens () ! for i in ipairs(self.tweens) do ! ! self.tweens[i]:update() ! end end

Heis, Muziko Kreito Universo: Project Documentation, 29

function kreito:add_delay (d) ! local de = u.delay:new() ! de.super = self ! de:set(d) ! self.delays[#self.delays+1] = de end function kreito:update_delays () ! for i in ipairs(self.delays) do ! ! self.delays[i]:update() ! end end --ai functions function kreito:birth_state () ! self.delta_health = 0 ! self.delta_energy = -u.slow_rate * u.time_elapse ! self.max_speed = u.stop_rate * u.time_elapse ! self.delta_pitch = self:pitch_match(0, false) ! --go to follow parent ! if self.age > 1/100 then ! ! self:anim_move() ! ! self:change_state("follow_parent") ! end end function kreito:follow_parent_state () ! if self.age > 1/10 then ! ! if self.parent_kreito ~= nil then ! ! ! u.remove(self.parent_kreito.children_kreito, self) ! ! end ! ! self.parent_kreito = nil ! end ! self.delta_health = 0 ! self.delta_energy = -u.slow_rate * u.time_elapse ! --go to wander ! if self.parent_kreito == nil then ! ! self.delta_pitch = 0 ! ! self:anim_move() ! ! self:change_state("wander") ! else ! ! self.delta_pitch = self:pitch_match(self.parent_kreito.pitch, true) ! ! self.max_speed = u.run_rate * u.time_elapse ! ! self:steer("arrive", self.parent_kreito) ! end end function kreito:clear_playmates () ! while self.playmates[1] do ! ! u.remove(self.playmates[#self.playmates].playmates, self) ! ! self.playmates[#self.playmates] = nil ! end end function kreito:clear_children () ! while self.children_kreito[1] do ! ! self.children_kreito[#self.children_kreito].parent_kreito = nil ! ! self.children_kreito[#self.children_kreito] = nil ! end end function kreito:wander_state () ! self:clear_playmates() ! self.delta_health = 0 ! self.delta_energy = -u.slow_rate * u.time_elapse! ! self.max_speed = u.walk_rate * u.time_elapse ! self.delta_pitch = self:pitch_match(math.random() * 12, true) ! self:steer("wander") ! --go to hunt ! if self.health < 1/5 then ! ! self:anim_flee()

Heis, Muziko Kreito Universo: Project Documentation, 30

! ! self:change_state("hunt") ! --go to sleep ! elseif self.energy < 1/5 then ! ! self:anim_sleep() ! ! self:change_state("sleep") ! --go to procreate ! elseif (self.energy + self.health + self.age) > #u.kreito_types * 8/3 * ! ! u.kreitoj_count[self.kreito_type] / u.max_kreitoj then ! ! self:anim_procreate() ! ! self:change_state("procreate") ! ! self:add_delay{5000, 'make_child'} ! --go to pursue(playmate) ! elseif (self.energy + self.health) > 3/2 then ! ! self:anim_flee() ! ! self:change_state("pursue") ! end end function kreito:sleep_state () ! self:clear_playmates() ! self.delta_health = 0 ! self.delta_energy = u.fast_rate * u.time_elapse ! self.max_speed = u.stop_rate * u.time_elapse ! self.delta_pitch = self:pitch_match(0, true) ! self:mvmt_stop() ! --go to wander ! if self.energy > 1 then ! ! self:anim_move() ! ! self:change_state("wander") ! end end function kreito:pursue_state () ! --go to wander's ! if self.energy < 1/4 then ! ! self:clear_playmates() ! ! self:anim_move() ! ! self:change_state("wander") ! elseif self.playmates[1] == nil then ! ! self:find_playmate() ! ! self.delta_pitch = 0 ! ! self:steer("wander") ! else ! ! self.delta_pitch = self:pitch_match(self.playmates[1].pitch, false) ! ! self:steer("arrive", self.playmates[1]) ! ! --go to play ! ! if self.magnitude < 1/10 then ! ! ! self:change_anim_play() ! ! ! self:change_state("play") ! ! ! self.playmates[1]:change_anim_play() ! ! ! self.playmates[1]:change_state("play") ! ! end ! end ! self.delta_health = 0 ! self.delta_energy = -u.mid_rate * u.time_elapse ! self.max_speed = u.run_rate * u.time_elapse end function kreito:find_playmate () ! local bidder ! local high_energy = 0 ! --find the kreito with highest energy in range ! for i in pairs(u.kreitoj) do ! ! if i ~= self.name and u.kreitoj[i] ~= nil then ! ! ! local st = u.kreitoj[i].current_state ! ! ! if st == "wander" or st == "pursue" or st == "play" then ! ! ! ! local l_x = u.kreitoj[i].position_x - self.position_x ! ! ! ! local l_y = u.kreitoj[i].position_y - self.position_y

Heis, Muziko Kreito Universo: Project Documentation, 31

! ! ! ! local l_z = u.kreitoj[i].position_z - self.position_z ! ! ! ! local l_m2 = (l_x)^2 + (l_y)^2 + (l_z)^2 ! ! ! ! if l_m2 < 4096 then --4096 = 64^2 ! ! ! ! ! local n_energy = u.kreitoj[i].energy ! ! ! ! ! if n_energy > high_energy and n_energy > 1/2 then ! ! ! ! ! ! bidder = u.kreitoj[i] ! ! ! ! ! ! high_energy = n_energy ! ! ! ! ! end ! ! ! ! end ! ! ! end ! ! end ! end ! --set up play relationship ! if bidder ~= nil then ! ! self.playmates[1] = bidder ! ! bidder.playmates[#bidder.playmates+1] = self ! ! bidder:change_state("pursue") ! end end function kreito:play_state () ! --go to wander's ! if self.energy < 1/4 then ! ! self:clear_playmates() ! ! self:anim_move() ! ! self:change_state("wander") ! elseif self.playmates[1] == nil then ! ! self:anim_move() ! ! self:change_state("wander") ! else ! ! self.delta_health = 0 ! ! self.delta_energy = -u.fast_rate * u.time_elapse ! ! self.max_speed = u.stop_rate * u.time_elapse ! ! self.delta_pitch = self:pitch_match(self.playmates[1].pitch, true) ! ! self:mvmt_stop() ! end end function kreito:change_anim_play () ! local r = "anim_play" .. math.ceil(math.random() * 4) ! self[r](self) end function kreito:procreate_state () ! self.delta_health = -u.fast_rate * u.time_elapse ! self.delta_energy = -u.fast_rate * u.time_elapse ! self.max_speed = u.stop_rate * u.time_elapse ! self.delta_pitch = self:pitch_match(0, false) ! self:mvmt_stop() ! self:clear_playmates() end function kreito:hunt_state () ! self:clear_playmates() ! self.delta_health = 0 ! self.delta_energy = -u.mid_rate * u.time_elapse ! self.max_speed = u.run_rate * u.time_elapse ! --go to fight ! if self.predator ~= nil then ! ! self.prey = nil ! ! self.delta_pitch = self:pitch_match(self.predator.pitch, false) ! ! self:steer("arrive", self.predator) ! ! if self.magnitude < 1/10 then ! ! ! self:change_anim_play() ! ! ! self:change_state("fight") ! ! end ! --go to wander ! elseif self.prey == nil or self.magnitude > 32 then ! ! self:find_prey()

Heis, Muziko Kreito Universo: Project Documentation, 32

! ! self.delta_pitch = 0 ! ! self:steer("wander") ! else ! ! self.delta_pitch = self:pitch_match(self.prey.pitch, false) ! ! self:steer("arrive", self.prey) ! ! --go to fight ! ! if self.magnitude < 1/10 then ! ! ! self:change_anim_play() ! ! ! self:change_state("fight") ! ! ! self.prey:decide_provoked(self) ! ! end ! end end function kreito:decide_provoked (pred) ! self.predator = pred ! --go to fight ! if self.health > 1/10 or self.current_state == "hunt" then ! ! self:change_anim_play() ! ! self:change_state("fight") ! --go to flee ! else ! ! self:anim_flee() ! ! self:change_state("flee") ! end end function kreito:find_prey () ! local bidder = nil ! local low_health = 1 ! --find kreito with lowest health in range ! for i in pairs(u.kreitoj) do ! ! if i ~= self.name and u.kreitoj[i] ~= nil then ! ! ! local st = u.kreitoj[i].current_state ! ! ! if st == "wander" or st == "sleep" or st == "hunt" then ! ! ! ! local l_x = u.kreitoj[i].position_x - self.position_x ! ! ! ! local l_y = u.kreitoj[i].position_y - self.position_y ! ! ! ! local l_z = u.kreitoj[i].position_z - self.position_z ! ! ! ! local l_m2 = (l_x)^2 + (l_y)^2 + (l_z)^2 ! ! ! ! if l_m2 < 16384 then --16384 = 128^2 ! ! ! ! ! local n_health = u.kreitoj[i].health ! ! ! ! ! if n_health < low_health then ! ! ! ! ! ! bidder = u.kreitoj[i] ! ! ! ! ! ! low_health = n_health ! ! ! ! ! end ! ! ! ! end ! ! ! end ! ! end ! end ! --set up predator and prey relationship ! if bidder ~= nil then ! ! self.prey = bidder ! ! if self.prey.current_state == "hunt" then ! ! ! self.prey.predator = self ! ! end ! end end function kreito:fight_state () ! self:clear_playmates() ! self.delta_health = -u.fast_rate * u.time_elapse ! self.delta_energy = -u.fast_rate * u.time_elapse ! self.max_speed = u.stop_rate * u.time_elapse ! self:mvmt_stop() ! --go to chase state ! if self.prey ~= nil then ! ! self.delta_pitch = self:pitch_match(self.prey.pitch, false) ! ! if self.prey.current_state == "flee" then

Heis, Muziko Kreito Universo: Project Documentation, 33

! ! ! self:anim_flee() ! ! ! self:change_state("chase") ! ! end ! --go to flee state ! elseif self.predator ~= nil then ! ! self.delta_pitch = self:pitch_match(self.predator.pitch, false) ! ! if self.health < 1/20 then ! ! ! self:anim_flee() ! ! ! self:change_state("flee") ! ! end ! --go to wander state ! else ! ! self.delta_pitch = 0 ! ! self:anim_move() ! ! self:change_state("wander") ! end end function kreito:chase_state () ! if self.prey ~= nil then ! ! self.delta_pitch = self:pitch_match(self.prey.pitch, false) ! ! self.delta_health = -u.fast_rate * u.time_elapse ! ! self.delta_energy = -u.fast_rate * u.time_elapse ! ! self.max_speed = u.fast_rate * u.time_elapse ! ! self:steer("arrive", self.prey) ! -- go to wander state ! else ! ! self:anim_move() ! ! self:change_state("wander") ! end end function kreito:flee_state () ! self:clear_playmates() ! self.delta_health = -u.fast_rate * u.time_elapse ! self.delta_energy = -u.fast_rate * u.time_elapse ! self.max_speed = u.run_rate * u.time_elapse ! if self.predator ~= nil then ! ! self.delta_pitch = self:pitch_match(self.predator.pitch, false) ! ! self:steer("flee", self.predator) ! --go to wander state ! else ! ! self:anim_move() ! ! self:change_state("wander") ! end end function kreito:death_state () ! self.health = 0 ! self.energy = 0! ! self.max_speed = 0 ! self.delta_pitch = self:pitch_match(0, true) ! self:mvmt_stop() end function kreito:make_child () ! self:anim_move() ! self:change_state("wander") ! --find an empty slot ! local childnum = nil ! for i = 1, u.max_kreitoj do ! ! if u.kreitoj[i] == nil then ! ! ! childnum = i ! ! ! break ! ! end ! end ! --make a kreito of the correct kind in the empty slot ! if childnum ~= nil then ! ! u.kreitoj[childnum] = u[self.kreito_type]:new()

Heis, Muziko Kreito Universo: Project Documentation, 34

! ! local c = u.kreitoj[childnum] ! ! c:setup() ! ! c.name = childnum ! ! c.parent_kreito = self ! ! self.children_kreito[#self.children_kreito+1] = c ! ! c:set_position{self.position_x, self.position_y, self.position_z} ! ! c:set_rotate{self.rotate_r, self.rotate_x, self.rotate_y, self.rotate_z} ! ! c:add_tween{0, 1, 2000, 'linear', 'alpha'} ! end end function kreito:terminate () ! self:cancel_tweens() ! --end all relationships ! self:clear_playmates() ! self:clear_children() ! if self.predator ~= nil then ! ! self.predator.health = 1 ! ! self.predator.prey = nil ! elseif self.prey ~= nil then ! ! self.prey.health = 1 ! ! self.prey.predator = nil ! end ! --delete this from the great array ! u.kreitoj[self.name] = nil end function kreito:pitch_match (t, cd) ! local direction = 1 ! if cd == false then ! ! direction = -1 ! end ! if t > self.pitch then ! ! return u.pitch_rate * direction ! else ! ! return -u.pitch_rate * direction ! end end

File: kreito_template.lua
a_kreito = {} function a_kreito:setup_faction() ! self.kreito_type = "a_kreito" ! self.faction_health = x/12 * u.slow_rate ! self.faction_energy = 12-x/12 * u.slow_rate ! --setup animation parameters ! self.tailflip = 0 end function a_kreito:draw() ! --age calculation ! u.sketch:glpushmatrix() ! self:setup_sketch() ! --main ! u.sketch:glpopmatrix() end function a_kreito:anim_move() ! self:cancel_tweens() ! --tweens and sets end function a_kreito:anim_procreate() ! self:cancel_tweens() ! --tweens and sets end function a_kreito:anim_sleep() ! self:cancel_tweens() ! --tweens and sets

Heis, Muziko Kreito Universo: Project Documentation, 35

end function a_kreito:anim_death() ! self:cancel_tweens() ! --tweens and sets end function a_kreito:anim_flee() ! self:cancel_tweens() ! --tweens and sets end --these all end with 'change_anim_play' function call function a_kreito:anim_play1() ! self:cancel_tweens() ! --tweens and sets end function a_kreito:anim_play2() ! self:cancel_tweens() ! --tweens and sets end function a_kreito:anim_play3() ! self:cancel_tweens() ! --tweens and sets end function a_kreito:anim_play4() ! self:cancel_tweens() ! --tweens and sets end u.a_kreito = u.createClass(kreito, a_kreito)

File: radiuso.lua
--radiuso radiuso = {} function radiuso:setup_faction() ! self.kreito_type = "radiuso" ! self.faction_health = 8/12 * u.slow_rate ! self.faction_energy = 4/12 * u.slow_rate ! self.spin = 0 ! self.radius = 2/3 ! self.space = 7/5 ! self.translate = 1 ! self.flip = 0 ! self.outradius = 0 ! self.tentacles = 1 end function radiuso:draw() ! self.tentacles = self.age * 13 ! u.sketch:glpushmatrix() ! self:setup_sketch() ! --head ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha) ! u.sketch:glpushmatrix() ! u.sketch:sphere(1) ! u.sketch:glpopmatrix() ! --tentacles ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha*2/3) ! u.sketch:glrotate(self.flip, -1, 0, 0) ! u.sketch:gltranslate(0, 0, -self.space * self.translate) ! for i = 0, self.tentacles do ! ! u.sketch:glpushmatrix() ! ! u.sketch:glrotate(self.spin + i * 360 / self.tentacles, 0, 0, 1) ! ! u.sketch:gltranslate(0, -self.radius, 0) ! ! u.sketch:sphere(1/3) ! ! u.sketch:glrotate(self.outradius, -1, 0, -1) ! ! u.sketch:gltranslate(0, 0, -self.space) ! ! u.sketch:cylinder(1/3, 0, 1)

Heis, Muziko Kreito Universo: Project Documentation, 36

! ! u.sketch:glpopmatrix() ! end ! u.sketch:glpopmatrix() end function radiuso:anim_move() ! self:cancel_tweens() ! self:add_tween{self.space, 6/5, 500, 'sine', 'space'} ! self:add_tween{self.outradius, -10, 500, 'sine', 'outradius', 'open_to_push'} ! self.spin = 0 ! self.radius = 2/3 ! self.translate = 1 ! self.flip = 0 end function radiuso:push_forward() ! self:cancel_tweens() ! self:add_tween{self.spin, 360, 3000, 'sine', 'spin'} ! self:add_tween{self.radius, 2/3, 3000, 'sine', 'radius'} ! self:add_tween{self.space, 6/5, 3000, 'sine', 'space'} ! self:add_tween{self.outradius, -10, 3000, 'sine', 'outradius', 'open_to_push'} end function radiuso:open_to_push() ! self:cancel_tweens() ! self:add_tween{self.radius, 4/3, 1000, 'sine', 'radius'} ! self:add_tween{self.space, 2, 1000, 'sine', 'space'} ! self:add_tween{self.outradius, 30, 1000, 'sine', 'outradius', 'push_forward'} ! self.spin = 0 end function radiuso:anim_procreate() ! self:cancel_tweens() ! self:add_tween{self.radius, 3/2, 1000, 'sine', 'radius'} ! self:add_tween{self.translate, 0, 1000, 'sine', 'translate'} ! self:add_tween{self.flip, -90, 1000, 'sine', 'flip'} ! self:add_tween{self.outradius, 90, 1000, 'sine', 'outradius', 'anim_procreate_spin'} ! self.space = 7/5 ! self.spin = 0 end function radiuso:anim_procreate_spin() ! self:cancel_tweens() ! self:add_tween{0, 360, 750, 'linear', 'spin', 'anim_procreate_spin'} end function radiuso:anim_sleep() ! self:cancel_tweens() ! self:add_tween{self.flip, 90, 1000, 'sine', 'flip'} ! self.space = 7/5 ! self.outradius = 0 ! self.spin = 0 ! self.radius = 2/3 ! self.translate = 1 end function radiuso:anim_death() ! self:cancel_tweens() ! self:add_tween{self.flip, -90, 1000, 'sine', 'flip'} ! self.space = 7/5 ! self.outradius = 0 ! self.spin = 0 ! self.radius = 2/3 ! self.translate = 1 end function radiuso:anim_flee() ! self:cancel_tweens() ! self:add_tween{0, 360, 500, 'linear', 'spin', 'anim_flee'} ! self.space = 7/5 ! self.outradius = 0 ! self.radius = 2/3 ! self.translate = 1

Heis, Muziko Kreito Universo: Project Documentation, 37

! self.flip = 0 end function radiuso:anim_play1() ! self:cancel_tweens() ! self:add_tween{0, 360, 2000, 'sine', 'spin', 'change_anim_play'} ! self.space = 7/5 ! self.outradius = 0 ! self.radius = 2/3 ! self.translate = 1 ! self.flip = 0 end function radiuso:anim_play2() ! self:cancel_tweens() ! self:add_tween{self.flip, 180, 1000, 'sine', 'flip'} ! self:add_tween{self.radius, 0, 1000, 'sine', 'radius', 'anim_play2_exit'} ! self.space = 7/5 ! self.outradius = 0 ! self.spin = 0 ! self.translate = 1 end function radiuso:anim_play2_exit() ! self:cancel_tweens() ! self:add_tween{self.flip, 0, 1000, 'sine', 'flip'} ! self:add_tween{self.radius, 2/3, 1000, 'sine', 'radius', 'change_anim_play'} end function radiuso:anim_play3() ! self:cancel_tweens() ! self:add_tween{self.flip, -90, 1000, 'sine', 'flip'} ! self:add_tween{self.outradius, 30, 1000, 'sine', 'outradius'} ! self:add_tween{0, 360, 1000, 'sine', 'spin', 'anim_play3_exit'} ! self.space = 7/5 ! self.radius = 2/3 ! self.translate = 1 end function radiuso:anim_play3_exit() ! self:cancel_tweens() ! self:add_tween{self.flip, 0, 1000, 'sine', 'flip'} ! self:add_tween{self.outradius, 0, 1000, 'sine', 'outradius', 'change_anim_play'} end function radiuso:anim_play4() ! self:cancel_tweens() ! self:add_tween{self.translate, 0, 1000, 'sine', 'translate'} ! self:add_tween{self.radius, 3/2, 1000, 'sine', 'radius'} ! self:add_tween{self.outradius, 90, 1000, 'sine', 'outradius'} ! self:add_tween{self.flip, -45, 1000, 'sine', 'flip'} ! self:add_tween{0, 360, 1000, 'linear', 'spin', 'anim_play4_exit'} ! self.space = 7/5 end function radiuso:anim_play4_exit() ! self:cancel_tweens() ! self:add_tween{self.translate, 1, 1000, 'sine', 'translate'} ! self:add_tween{self.radius, 2/3, 1000, 'sine', 'radius'} ! self:add_tween{self.outradius, 0, 1000, 'sine', 'outradius'} ! self:add_tween{self.flip, 0, 1000, 'sine', 'flip'} ! self:add_tween{0, 360, 1000, 'linear', 'spin', 'change_anim_play'} end u.radiuso = u.createClass(kreito, radiuso)

File: flugilo.lua
--flugilo flugilo = {} function flugilo:setup_faction() ! self.kreito_type = "flugilo" ! self.faction_health = 9/12 * u.slow_rate

Heis, Muziko Kreito Universo: Project Documentation, 38

! self.faction_energy = 3/12 * u.slow_rate ! self.wingflap = 0 ! self.wingflip = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailspace = 4/5 ! self.tailjoints = 5 ! self.wingsperside = 1 ! self.wingspace = 10 ! self.tailtwirl = 0 end function flugilo:draw() ! --age ! self.tailjoints = self.age * 9 + 1 ! self.wingsperside = self.age * 5 ! u.sketch:glpushmatrix() ! self:setup_sketch() ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha) ! --body ! u.sketch:glpushmatrix() ! u.sketch:glscale(1, 2/3, 1) ! u.sketch:cylinder(1/2, 1/2, 2/3) ! u.sketch:glpopmatrix() ! --head ! u.sketch:glpushmatrix() ! u.sketch:gltranslate(0, 0, self.neckspace) ! u.sketch:glrotate(self.nod, -1, 0, -1) ! u.sketch:gltranslate(0, 0, 1/2) ! u.sketch:glscale(1, 2/3, 1) ! u.sketch:cylinder(0, 1/2, 2/3) ! u.sketch:glpopmatrix() ! --wings ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha*2/3) ! local wingside = {-1, 1} ! for k=1, #wingside do ! for i=0, self.wingsperside do ! ! ! u.sketch:glpushmatrix() ! ! ! local _rot = self.wingflip + self.wingspace*(i-self.wingsperside/2) + ! ! ! ! wingside[k]*(90+self.wingflap) + 90 ! ! ! u.sketch:glrotate(90, 0, 1, 0) ! ! ! u.sketch:glrotate(_rot, 1, 0, 0) ! ! ! u.sketch:glscale(1, 2/3, 1) ! ! ! u.sketch:gltranslate(0, 0, 6/5) ! ! ! u.sketch:cylinder(0, 1/2, 2/3) ! ! ! u.sketch:glpopmatrix() ! end end ! --tail ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha/3) ! u.sketch:gltranslate(0, 0, -11/10) ! for i=0, self.tailjoints do ! ! ! u.sketch:glpushmatrix() ! ! ! u.sketch:glrotate(self.delta_azimuth * 4 * i, 0, -1, 0) ! ! ! u.sketch:glrotate(self.delta_elevation * 4 * i, -1, 0, 0) ! ! ! u.sketch:glrotate(self.tailflip * i, -1, 0 ,-1) ! ! ! u.sketch:glrotate(self.tailtwirl * i / 2, 0, 1, 1) ! ! ! u.sketch:gltranslate(0, 0, -self.tailspace*i) ! ! ! u.sketch:sphere(1/3) ! ! ! u.sketch:glpopmatrix() ! end ! u.sketch:glpopmatrix() end function flugilo:anim_move() ! self:cancel_tweens() ! self:flap_wings()

Heis, Muziko Kreito Universo: Project Documentation, 39

! self.wingflip = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function flugilo:flap_wings() ! self:cancel_tweens() ! self:add_tween{self.wingflap, -45, 1000, 'sine', 'wingflap', 'flap_wings_up'} end function flugilo:flap_wings_up() ! self:cancel_tweens() ! self:add_tween{-45, 45, 1000, 'sine', 'wingflap', 'flap_wings'} end function flugilo:anim_procreate() ! self:cancel_tweens() ! self:add_tween{self.nod, -15, 1000, 'sine', 'nod'} ! self:add_tween{0, 360, 1000, 'linear', 'wingflip'} ! self:add_tween{0, 720, 1000, 'linear', 'tailtwirl', 'anim_procreate_up'} ! self.wingflap = 0 ! self.tailflip = 0 ! self.neckspace = 1 end function flugilo:anim_procreate_up() ! self:cancel_tweens() ! self:add_tween{-15,15,1000,'sine','nod'} ! self:add_tween{0,360,1000,'linear','wingflip'} ! self:add_tween{0,720,1000, 'linear', 'tailtwirl', 'anim_procreate'} end function flugilo:anim_sleep() ! self:cancel_tweens() ! self:add_tween{self.wingflap, -15, 1000, 'sine', 'wingflap'} ! self:add_tween{self.nod, -15, 1000, 'sine', 'nod'} ! self:add_tween{self.tailflip, 15, 1000, 'sine', 'tailflip'} ! self.wingflip = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function flugilo:anim_death() ! self:cancel_tweens() ! self:add_tween{self.wingflap, -90, 1000, 'sine', 'wingflap'} ! self:add_tween{self.nod, -30, 1000, 'sine', 'nod'} ! self:add_tween{self.tailflip, 30, 1000, 'sine', 'tailflip'} ! self.wingflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function flugilo:anim_flee() ! self:cancel_tweens() ! self:add_tween{0, 360, 750, 'linear', 'wingflip'} ! self:add_tween{0, 720, 750, 'linear', 'tailtwirl', 'anim_flee'} ! self.wingflap = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 end function flugilo:anim_play1() ! self:cancel_tweens() ! self:add_tween{0, 720, 2000, 'linear', 'tailtwirl', 'change_anim_play'} ! self.wingflap = 0 ! self.wingflip = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1

Heis, Muziko Kreito Universo: Project Documentation, 40

end function flugilo:anim_play2() ! self:cancel_tweens() ! self:add_tween{self.neckspace, 7/5, 1000, 'sine', 'neckspace', 'anim_play2_exit'} ! self.wingflap = 0 ! self.wingflip = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.tailtwirl = 0 end function flugilo:anim_play2_exit() ! self:cancel_tweens() ! self:add_tween{self.neckspace, 1, 1000, 'sine', 'neckspace', 'change_anim_play'} end function flugilo:anim_play3() ! self:cancel_tweens() ! self:add_tween{self.wingflap, 90, 1000, 'sine', 'wingflap', 'anim_play3_exit'} ! self.wingflip = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function flugilo:anim_play3_exit() ! self:cancel_tweens() ! self:add_tween{self.wingflap, 0, 1000, 'sine', 'wingflap', 'change_anim_play'} end function flugilo:anim_play4() ! self:cancel_tweens() ! self:add_tween{self.tailflip, -45, 1000, 'sine', 'tailflip', 'anim_play4_exit'} ! self.wingflap = 0 ! self.wingflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function flugilo:anim_play4_exit() ! self:cancel_tweens() ! self:add_tween{self.tailflip, 0, 1000, 'sine', 'tailflip', 'change_anim_play'} end u.flugilo = u.createClass(kreito, flugilo)

File: konko.lua
--konko konko = {} function konko:setup_faction() ! self.kreito_type = "konko" ! self.faction_health = 3/12 * u.slow_rate ! self.faction_energy = 9/12 * u.slow_rate ! self.radius = 2/3 ! self.feet = 3 ! self.spin = 0 ! self.coneflip = 0 ! self.feetflip = 0 ! self.coneradius = 10 ! self.conespin = 0 ! self.feettrans = 1 end function konko:draw() ! --age ! self.feet = self.age * 9 + 1 ! u.sketch:glpushmatrix() ! self:setup_sketch() ! --head

Heis, Muziko Kreito Universo: Project Documentation, 41

! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha) ! u.sketch:glpushmatrix() ! u.sketch:sphere(2/3) ! u.sketch:glpopmatrix() ! --shell ! u.sketch:glpushmatrix() ! u.sketch:glrotate(self.coneflip, -1, 0, 0) ! u.sketch:glrotate(self.conespin, 0, self.coneradius, -1) ! u.sketch:gltranslate(0, 5/2, 0) ! u.sketch:glrotate(90, 1, 0, 0) ! u.sketch:cylinder(2/3, 0, 9/5) ! u.sketch:glpopmatrix() ! --feet ! u.sketch:glrotate(self.feetflip, -1, 0, 0) ! u.sketch:gltranslate(0, -self.feettrans, 0) ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha * 2 / 3) ! for i=0, self.feet do ! ! u.sketch:glpushmatrix() ! ! u.sketch:glrotate(self.spin + i * 360 / self.feet, 0, -self.radius, 0) ! ! u.sketch:gltranslate(0, 0, self.radius) ! ! u.sketch:sphere(1/3) ! ! u.sketch:glpopmatrix() ! end ! u.sketch:glpopmatrix() end function konko:anim_move() ! self:cancel_tweens() ! self:add_tween{self.coneflip, 15, 1000, 'sine', 'coneflip'} ! self:add_tween{self.feetflip, -15, 1000, 'sine', 'feetflip', 'spin_feet'} ! self.radius = 2/3 ! self.spin = 0 ! self.conespin = 0 ! self.feettrans = 1 end function konko:spin_feet() ! self:cancel_tweens() ! self:add_tween{0, 360, 1000, 'linear', 'spin', 'spin_feet'}! end function konko:twirl_cone() ! self:cancel_tweens() ! self:add_tween{0, 360, 1000, 'linear', 'conespin', 'twirl_cone'} end function konko:spin_and_twirl() ! self:cancel_tweens() ! self:add_tween{0, 360, 1000, 'linear', 'spin'}! ! self:add_tween{0, 360, 1000, 'linear', 'conespin', 'spin_and_twirl'} end function konko:anim_procreate() ! self:cancel_tweens() ! self:add_tween{self.feettrans, 0, 1000, 'sine', 'feettrans'} ! self:add_tween{self.radius, 6/5, 1000, 'sine', 'radius', 'spin_and_twirl'} ! self.spin = 0 ! self.coneflip = 0 ! self.feetflip = 0 ! self.conespin = 0 end function konko:anim_sleep() ! self:cancel_tweens() ! self:add_tween{self.coneflip, 90, 1000, 'sine', 'coneflip'} ! self.radius = 2/3 ! self.spin = 0 ! self.feetflip = 0 ! self.conespin = 0 ! self.feettrans = 1 end

Heis, Muziko Kreito Universo: Project Documentation, 42

function konko:anim_death() ! self:cancel_tweens() ! self:add_tween{self.coneflip, 180, 1000, 'sine', 'coneflip'} ! self:add_tween{self.feetflip, -180, 1000, 'sine', 'feetflip'} ! self.radius = 2/3 ! self.spin = 0 ! self.conespin = 0 ! self.feettrans = 1 end function konko:anim_flee() ! self:cancel_tweens() ! self:add_tween{self.coneflip, 90, 1000, 'sine', 'coneflip'} ! self:add_tween{self.feetflip, -90, 1000, 'sine', 'feetflip'} ! self:add_tween{self.radius, 1, 1000, 'sine', 'radius', 'spin_and_twirl'} ! self.spin = 0 ! self.conespin = 0 ! self.feettrans = 1 end function konko:anim_play1() ! self:cancel_tweens() ! self:add_tween{0, 360, 2000, 'linear', 'conespin'} ! self:add_tween{self.coneflip, 15, 2000, 'sine', 'coneflip', 'change_anim_play'} ! self.radius = 2/3 ! self.spin = 0 ! self.feetflip = 0 ! self.conespin = 0 ! self.feettrans = 1 end function konko:anim_play2() ! self:cancel_tweens() ! self:add_tween{self.feetflip, 90, 2000, 'sine', 'feetflip', 'change_anim_play'} ! self.radius = 2/3 ! self.spin = 0 ! self.coneflip = 0 ! self.conespin = 0 ! self.feettrans = 1 end function konko:anim_play3() ! self:cancel_tweens() ! self:add_tween{0, 360, 1000, 'linear', 'spin'} ! self:add_tween{self.feettrans, 0, 1000, 'sine', 'feettrans'} ! self:add_tween{self.radius, 6/5, 1000, 'sine', 'radius', 'anim_play3_exit'} ! self.spin = 0 ! self.coneflip = 0 ! self.feetflip = 0 ! self.conespin = 0 end function konko:anim_play3_exit() ! self:cancel_tweens() ! self:add_tween{0, 360, 1000, 'linear', 'spin'} ! self:add_tween{self.feettrans, 1, 1000, 'sine', 'feettrans'} ! self:add_tween{self.radius, 2/3, 1000, 'sine', 'radius', 'change_anim_play'} end function konko:anim_play4() ! self:cancel_tweens() ! self:add_tween{self.radius, -2/3, 1000, 'sine', 'radius', 'anim_play4_exit'} ! self.spin = 0 ! self.coneflip = 0 ! self.feetflip = 0 ! self.conespin = 0 ! self.feettrans = 1 end function konko:anim_play4_exit() ! self:cancel_tweens() ! self:add_tween{self.radius, 2/3, 1000, 'sine', 'radius', 'change_anim_play'}

Heis, Muziko Kreito Universo: Project Documentation, 43

end u.konko = u.createClass(kreito, konko)

File: streko.lua
--streko streko = {} function streko:setup_faction() ! self.kreito_type = "streko" ! self.faction_health = 11/12 * u.slow_rate ! self.faction_energy = 1/12 * u.slow_rate ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailspace = 8/5 ! self.tailjoints = 5 ! self.orbit = 0 ! self.tailtwirl = 0 end function streko:draw() ! --age ! self.tailjoints = self.age * 12 + 1 ! u.sketch:glpushmatrix() ! self:setup_sketch() ! --main ! for i=0, self.tailjoints do ! ! if i < 5 then ! ! ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, ! ! ! ! self.alpha*(6-i)/6) ! ! else ! ! ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha/3) ! ! end ! ! u.sketch:glpushmatrix() ! ! if i == 0 then ! ! ! u.sketch:glrotate(self.nod, 0, 1, 0) ! ! ! u.sketch:gltranslate(0, 0, self.neckspace - 1/2) ! ! else ! ! ! u.sketch:glrotate(self.delta_azimuth * 4 * i, 0, -1, 0) ! ! ! u.sketch:glrotate(self.delta_elevation * 4 * i, -1, 0, 0) ! ! ! u.sketch:glrotate(self.tailflip * i, -1, 0 ,-1) ! ! ! u.sketch:glrotate(self.tailtwirl * i / 2, 0, 1, 1) ! ! ! u.sketch:glrotate(self.orbit * i, 0, 1, 0) ! ! end ! ! u.sketch:gltranslate(0, 0, -self.tailspace * i) ! ! if i < 5 then ! ! ! u.sketch:sphere((6-i)/6) ! ! else ! ! ! u.sketch:sphere(1/3) ! ! end ! ! u.sketch:glpopmatrix() ! end ! u.sketch:glpopmatrix() end function streko:anim_move() ! self:cancel_tweens() ! self.orbit = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function streko:anim_procreate() ! self:cancel_tweens() ! self:add_tween{self.nod, -15, 1000, 'sine', 'nod'} ! self:add_tween{0, 360, 1000, 'linear', 'orbit'}

Heis, Muziko Kreito Universo: Project Documentation, 44

! self:add_tween{0, 720, 1000, 'linear', 'tailtwirl', 'anim_procreate_up'} ! self.tailflip = 0 ! self.neckspace = 1 end function streko:anim_procreate_up() ! self:cancel_tweens() ! self:add_tween{-15,15,1000,'sine','nod'} ! self:add_tween{0,360,1000,'linear','orbit'} ! self:add_tween{0,720,1000, 'linear', 'tailtwirl', 'anim_procreate'} end function streko:anim_sleep() ! self:cancel_tweens() ! self:add_tween{self.nod, -15, 1000, 'sine', 'nod'} ! self:add_tween{self.tailflip, 15, 1000, 'sine', 'tailflip'} ! self.orbit = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function streko:anim_death() ! self:cancel_tweens() ! self:add_tween{self.nod, -30, 1000, 'sine', 'nod'} ! self:add_tween{self.tailflip, 30, 1000, 'sine', 'tailflip'} ! self.orbit = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function streko:anim_flee() ! self:cancel_tweens() ! self:add_tween{0, 720, 750, 'linear', 'tailtwirl', 'anim_flee'} ! self.orbit = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 end function streko:anim_play1() ! self:cancel_tweens() ! self:add_tween{0, 720, 2000, 'linear', 'tailtwirl', 'change_anim_play'} ! self.orbit = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 end function streko:anim_play2() ! self:cancel_tweens() ! self:add_tween{self.neckspace, 7/5, 1000, 'sine', 'neckspace', 'anim_play2_exit'} ! self.orbit = 0 ! self.tailflip = 0 ! self.nod = 0 ! self.tailtwirl = 0 end function streko:anim_play2_exit() ! self:cancel_tweens() ! self:add_tween{self.neckspace, 1, 1000, 'sine', 'neckspace', 'change_anim_play'} end function streko:anim_play3() ! self:cancel_tweens() ! self:add_tween{0, 360, 2000, 'linear', 'orbit', 'change_anim_play'} ! self.tailflip = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function streko:anim_play4() ! self:cancel_tweens()

Heis, Muziko Kreito Universo: Project Documentation, 45

! self:add_tween{self.tailflip, -45, 1000, 'sine', 'tailflip', 'anim_play4_exit'} ! self.orbit = 0 ! self.nod = 0 ! self.neckspace = 1 ! self.tailtwirl = 0 end function streko:anim_play4_exit() ! self:cancel_tweens() ! self:add_tween{self.tailflip, 0, 1000, 'sine', 'tailflip', 'change_anim_play'} end u.streko = u.createClass(kreito, streko)

File: drivo.lua
drivo = {} function drivo:setup_faction() ! self.kreito_type = "drivo" ! self.faction_health = 1/12 * u.slow_rate ! self.faction_energy = 11/12 * u.slow_rate ! --setup animation parameters ! self.headspin = 0 ! self.neckspace = 0 ! self.armspin = 0 ! self.legspin = 0 ! self.armsforback = 0 ! self.legsforback = 0 ! self.armfan = 0 ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end function drivo:draw() ! --age calculation ! self.arms = self.age * 4 + 1 ! self.legs = self.age * 8 + 1 ! u.sketch:glpushmatrix() ! self:setup_sketch() ! --body ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha) ! u.sketch:glpushmatrix() ! u.sketch:glrotate(90, 1, 0, 0) ! u.sketch:glscale(1, 2/3, 1) ! u.sketch:cylinder(1/2, 1/2, 1/2) ! u.sketch:glpopmatrix() ! --head ! u.sketch:glpushmatrix() ! u.sketch:gltranslate(0, 1, 0) ! u.sketch:glrotate(self.headspin, 0, 1, 0) ! u.sketch:gltranslate(0, 0, self.neckspace) ! u.sketch:sphere(1/2) ! u.sketch:glpopmatrix() ! --arms ! u.sketch:glcolor(self.color.r, self.color.g, self.color.b, self.alpha * 2/3) ! u.sketch:glpushmatrix() ! u.sketch:glrotate(self.armsforback, 1, 0, 0) ! u.sketch:gltranslate(0, 1/2, 0) ! for i=0, self.arms do ! ! u.sketch:glpushmatrix() ! ! u.sketch:glrotate(i * 360 / (self.arms + 1) + self.armspin - 90, 0, 1, 0) ! ! u.sketch:gltranslate(0, 0, self.armspace-1/4) ! ! u.sketch:glrotate(self.armfan, 1, 0, 0) ! ! u.sketch:gltranslate(0, 0, 1/4) ! ! u.sketch:cylinder(0, 1/4, 1/2) ! ! u.sketch:glpopmatrix() ! end

Heis, Muziko Kreito Universo: Project Documentation, 46

! u.sketch:glpopmatrix() ! --legs ! u.sketch:glpushmatrix() ! u.sketch:glrotate(self.legsforback, 1, 0, 0) ! u.sketch:gltranslate(0, -3/4, 0) ! for i=0, self.legs do ! ! u.sketch:glpushmatrix() ! ! u.sketch:glrotate(i * 360 / (self.legs + 1) - 90 + self.legspin, 0, 1, 0) ! ! u.sketch:gltranslate(0, 0, self.legspace) ! ! u.sketch:glrotate(self.legfan, 1, 0, 0) ! ! u.sketch:gltranslate(0, -1/4, 0) ! ! u.sketch:glrotate(-90, 1, 0, 0) ! ! u.sketch:cylinder(1/4, 0, 1/2) ! ! u.sketch:glpopmatrix() ! end ! u.sketch:glpopmatrix() ! --close ! u.sketch:glpopmatrix() end function drivo:anim_move() ! self:cancel_tweens() ! --tweens and sets ! if self.armfan > 0 then ! ! self:add_tween{self.armfan, -15, 1000, 'sine', 'armfan'} ! else ! ! self:add_tween{self.armfan, 15, 1000, 'sine', 'armfan'} ! end ! if self.legsforback < 29 then ! ! self:add_tween{self.legsforback, 30, 500, 'sine', 'legsforback'} ! else ! ! self.legsforback = 30 ! end ! self:add_tween{0, 360, 1000, 'linear', 'legspin', 'anim_move'} ! self.armsforback = 0 ! self.headspin = 0 ! self.neckspace = 0 ! self.armspin = 0 ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end function drivo:anim_procreate() ! self:cancel_tweens() ! --tweens and sets ! if self.armfan > 0 then ! ! self:add_tween{self.armfan, -30, 500, 'sine', 'armfan'} ! else ! ! self:add_tween{self.armfan, 30, 500, 'sine', 'armfan'} ! end ! if self.legfan > 0 then ! ! self:add_tween{self.legfan, -30, 500, 'sine', 'legfan'} ! else ! ! self:add_tween{self.legfan, 30, 500, 'sine', 'legfan'} ! end ! if self.neckspace < 9/10 then ! ! self:add_tween{self.neckspace, 1, 500, 'sine', 'neckspace'} ! else ! ! self.neckspace = 1 ! end ! self:add_tween{0, 360, 500, 'linear', 'headspin'} ! self:add_tween{0, 360, 500, 'linear', 'armspin'} ! self:add_tween{0, 360, 500, 'linear', 'legspin', 'anim_procreate'} ! self.armsforback = 0 ! self.legsforback = 0 ! self.armspace = 1

Heis, Muziko Kreito Universo: Project Documentation, 47

! self.legspace = 1/3 end function drivo:anim_sleep() ! self:cancel_tweens() ! --tweens and sets ! self.headspin = 0 ! self.neckspace = 0 ! self.armspin = 0 ! self.legspin = 0 ! self.armsforback = 0 ! self.legsforback = 0 ! self:add_tween{self.armfan, -45, 1000, 'sine', 'armfan'} ! self:add_tween{self.legfan, 45, 1000, 'sine', 'legfan'} ! self.armspace = 1 ! self.legspace = 1/3 end function drivo:anim_death() ! self:cancel_tweens() ! --tweens and sets ! self.headspin = 0 ! self.neckspace = 0 ! self.armspin = 0 ! self.legspin = 0 ! self.armsforback = 0 ! self.legsforback = 0 ! self:add_tween{self.armfan, -90, 1000, 'sine', 'armfan'} ! self:add_tween{self.legfan, 90, 1000, 'sine', 'legfan'} ! self:add_tween{self.armspace, 0, 1000, 'sine', 'armspace'} ! self:add_tween{self.legspace, 0, 1000, 'sine', 'armspace'} end function drivo:anim_flee() ! self:cancel_tweens() ! --tweens and sets ! if self.armsforback < 89 then ! ! self:add_tween{self.armsforback, -90, 500, 'sine', 'armsforback'} ! else ! ! self.armsforback = -90 ! end ! if self.legsforback < 89 then ! ! self:add_tween{self.legsforback, 90, 500, 'sine', 'legsforback'} ! else ! ! self.legsforback = 90 ! end ! if self.armfan < 89 then ! ! self:add_tween{self.armfan, 90, 500, 'sine', 'armfan'} ! else ! ! self.armfan = 90 ! end ! self:add_tween{0, 360, 500, 'linear', 'armspin'} ! self:add_tween{0, 360, 500, 'linear', 'legspin', 'anim_flee'} ! self.headspin = 0 ! self.neckspace = 0 ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end --these all end with 'change_anim_play' function call function drivo:anim_play1() ! self:cancel_tweens() ! --tweens and sets ! if self.neckspace < 2/5 then ! ! self:add_tween{self.neckspace, 1/2, 1000, 'sine', 'neckspace'} ! else ! ! self:add_tween{self.neckspace, 0, 1000, 'sine', 'neckspace'} ! end

Heis, Muziko Kreito Universo: Project Documentation, 48

! self:add_tween{0, 360, 2000, 'linear', 'headspin', 'change_anim_play'} ! self.armspin = 0 ! self.legspin = 0 ! self.armsforback = 0 ! self.legsforback = 0 ! self.armfan = 0 ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end function drivo:anim_play2() ! self:cancel_tweens() ! --tweens and sets ! self.headspin = 0 ! self.neckspace = 0 ! self:add_tween{0, 360, 2000, 'linear', 'armspin', 'change_anim_play'} ! self.legspin = 0 ! self.armsforback = 0 ! self.legsforback = 0 ! self.armfan = 0 ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end function drivo:anim_play3() ! self:cancel_tweens() ! --tweens and sets ! self.headspin = 0 ! self.neckspace = 0 ! self.armspin = 0 ! self:add_tween{0, 360, 2000, 'linear', 'legspin', 'change_anim_play'} ! self.armsforback = 0 ! self.legsforback = 0 ! self.armfan = 0 ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end function drivo:anim_play4() ! self:cancel_tweens() ! --tweens and sets ! self.headspin = 0 ! self.neckspace = 0 ! self:add_tween{0, 360, 2000, 'linear', 'armspin', 'change_anim_play'} ! self.legspin = 0 ! self.armsforback = 0 ! self.legsforback = 0 ! if self.armfan < 89 then ! ! self:add_tween{self.armfan, 90, 1000, 'sine', 'armfan'} ! else ! ! self:add_tween{self.armfan, 0, 1000, 'sine', 'armfan'} ! end ! self.legfan = 0 ! self.armspace = 1 ! self.legspace = 1/3 end u.drivo = u.createClass(kreito, drivo)

Heis, Muziko Kreito Universo: Project Documentation, 49

File: mku_c74.txt
clear brgb 0. 0. 0. 1. hslider healthSlider 25 25 270 80 bgcolor healthSlider 1. 0.67 0.67 1. comment healthLabel 25 105 HEALTH textcolor healthLabel 1. 1. 1. 1. comment healthPointer 156 105 ▲ textcolor healthPointer 1. 1. 1. 1. hslider energySlider 25 165 270 80 bgcolor energySlider 0.67 1. 0.67 1. comment energyLabel 25 245 ENERGY textcolor energyLabel 1. 1. 1. 1. comment energyPointer 156 245 ▲ textcolor energyPointer 1. 1. 1. 1. toggle activeToggle 25 305 80 bgcolor activeToggle 0.67 0.5 1. 1. comment activeLabel 25 385 ACTIVE textcolor activeLabel 1. 1. 1. 1. button homeButton 215 305 80 bgcolor homeButton 0.67 1. 1. 1. comment homeLabel 215 385 HOME textcolor homeLabel 1. 1. 1. 1. set healthSlider 0.5 set energySlider 0.5 set activeToggle 1. bordercolor healthSlider 1. 1. 1. 1. bordercolor energySlider 1. 1. 1. 1. bordercolor activeToggle 1. 1. 1. 1. bordercolor homeButton 1. 1. 1. 1.

Sign up to vote on this title
UsefulNot useful