├── .gitignore ├── README.md ├── defkit ├── actions │ ├── basic │ │ ├── create.script │ │ └── destroy.script │ ├── basic2 │ │ ├── draw_score.script │ │ ├── set_alarm.script │ │ ├── set_score.script │ │ └── set_variable.script │ ├── control │ │ ├── test_chance.script │ │ └── test_instance_count.script │ ├── jump │ │ └── jump_to_position.script │ ├── main1 │ │ ├── play_animation.script │ │ ├── play_particlefx.script │ │ ├── play_sound.script │ │ ├── play_spine.script │ │ └── set_label_text.script │ ├── move │ │ ├── move_fixed.script │ │ ├── move_free.script │ │ ├── move_towards.script │ │ └── set_gravity.script │ └── room │ │ ├── go_to_room.script │ │ ├── next_room.script │ │ ├── previous_room.script │ │ └── restart_room.script ├── events │ ├── contact │ │ └── on_collision.script │ ├── input │ │ ├── on_button.script │ │ ├── on_button_press.script │ │ └── on_button_release.script │ ├── on_create.script │ ├── on_destroy.script │ ├── other │ │ └── on_animation_end.script │ └── time │ │ ├── on_alarm.script │ │ └── on_step.script ├── internal │ └── lookup.lua ├── object.script └── rooms.script ├── examples └── rooms │ ├── room0.collection │ ├── room1.collection │ ├── room2.collection │ └── rooms.collection ├── game.project ├── input └── game.input_binding ├── main ├── images │ └── logo.png ├── logo.atlas ├── main.collection ├── music.go ├── player.go ├── point.go └── sounds │ └── strings2.wav └── properties.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DefKit 2 | A Component based scripts library for [Defold](www.defold.com) engine inspired by the [Game Maker](http://www.yoyogames.com/gamemaker) studio visual scripting. 3 | 4 | # Usage 5 | 1. Add latest zip URL as a [dependency](http://www.defold.com/manuals/libraries/#_setting_up_library_dependencies) in your Defold project: `https://github.com/adamwestman/defkit/archive/master.zip` 6 | 7 | 2. Add the [object.script](https://github.com/adamwestman/defkit/blob/master/defkit/object.script) to your Game Object 8 | 9 | 3. Add an Event scripts to your Game Object 10 | 11 | 4. Add an Action scripts to your Game Object 12 | 13 | 5. Select the Action script and point its event url at the Event script 14 | 15 | # Docs 16 | Here are some of the common Event (input) and Action (output) -scripts 17 | 18 | ## [Events](https://docs.yoyogames.com/source/dadiospice/000_using%20gamemaker/events/index.html) 19 | Events are input from different sources to which you can react and connect one or many actions. These range from user-input such as keys being pressed, instance lifecycle such as create and destroy, or collision betwen different instances to name a few. 20 | 21 | ### General 22 | * on_create : invoked directly on create of the object. 23 | * on_destroy : invoked when the object is told to be removed. 24 | 25 | ### Input 26 | These scripts allow users to connect logic to input, as long as the referenced action_id is defined in the input definition file. 27 | 28 | * on_button : repeated for as long as the button is held down. 29 | * on_button_pressed : invoked once as the button is pressed down. 30 | * on_button_released : invoked once as the button is released after being pressed. 31 | 32 | ### Contact 33 | These scripts allow users to connect logic to [contact between objects](http://www.defold.com/manuals/physics/#_collision_objects), as long as the objects both have collision-objects and masks are correctly setup. 34 | 35 | * on_collision : repeated as long as the object matching the collision group is in contact. 36 | 37 | ### Time 38 | These script allow users to connect logic to events related to time, either user-defined alarms or the normal update-cycle. 39 | 40 | * on_alarm : invoked when the set amount of seconds have passed since the user-defined timer was started. 41 | * on_Step : invoked each cycle/frame. 42 | 43 | 44 | 45 | ## [Actions](https://docs.yoyogames.com/source/dadiospice/000_using%20gamemaker/actions/index.html) 46 | Actions are small blocks of logic that allow interraction in a multitude of ways; movement, creation and destruction to name a few. 47 | 48 | __Shared Information__ 49 | 50 | Event : All Actions come with an "event" url parameter, this is how you connect which Event is the cause of this Action. 51 | 52 | Target : Many but not all Actions also come with a Self, Other or Object Type parameter 53 | 54 | Relative: Let the set value be influenced by context based values, depending on Action this could be worl-position or existing velocity among other things. 55 | 56 | Variables: Many of the input-values also come with a "Var" option which is short for Variable. These enable passing dynamic values, either predefined or controlled using set_variable. 57 | 58 | ### Basic 59 | * create : tell a Factory to create one instance of it's targetted game-object, at the given location. 60 | * destroy : tell the targetted game-object to be destroyed instantly. 61 | 62 | ### Move 63 | The actions let the user change position over time for targetted object, if set to relative the existing movement-speed will be taken in-to account. 64 | 65 | * move_fixed : given one or more directions, North, West, South, East or diagonals inbetween. Randoms between the given directions and move at the assigned speed. 66 | * move_free : given an angle value, move in that direction at the given speed. 67 | 68 | ### Basic2 69 | 70 | * set_alarm : tell the specified alarm event to fire after a set amount of seconds. 71 | * set_score : set the current score value to the defined amount, or influence the existing by relative. 72 | * set_variable : set the specified variable to the defined number value, or influence the existing by relative. 73 | * draw_score : render the current score at the specified coordinate on the screen. 74 | 75 | ### Controll 76 | 77 | * test_chance : roll a dice with set amount of sides to see if it gives a 1, then invoke other actions. 78 | * test_instance_count : count the amount of objects to see if they are "equal (0)", "less than (-1)" or "more than(1)" the specified amount, then invoke other actions. 79 | 80 | 81 | ## Examples 82 | 83 | ### Properties 84 | ![properties example](https://github.com/adamwestman/defkit/blob/master/properties.png "Properties example") 85 | 86 | This example display a number of DefKit scripts along with Defold components Sprite and Collision Object, which together create an object that can move and on collision with "point" objects destroy them. 87 | -------------------------------------------------------------------------------- /defkit/actions/basic/create.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("factory", msg.url()) 8 | 9 | go.property("x_var", hash("")) 10 | go.property("x_val", 0) 11 | 12 | go.property("y_var", hash("")) 13 | go.property("y_val", 0) 14 | 15 | go.property("relative", false) 16 | 17 | local function get_position(self) 18 | local x_value = lookup.get_variable(self.x_var, self.x_val) 19 | local y_value = lookup.get_variable(self.y_var, self.y_val) 20 | 21 | local target_pos = vmath.vector3(x_value, y_value, 0) 22 | 23 | return target_pos 24 | end 25 | 26 | function on_message(self, message_id, message, sender) 27 | if sender == self.event then 28 | local position = get_position(self) 29 | if self.relative then 30 | position = position + go.get_world_position() 31 | end 32 | factory.create(self.factory, position) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /defkit/actions/basic/destroy.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- TARGETTING PROPERTIES 7 | go.property("target_self", false) 8 | go.property("target_other", false) 9 | go.property("target_type", hash("")) 10 | 11 | function on_message(self, message_id, message, sender) 12 | if sender == self.event then 13 | if self.target_self then 14 | go.delete() 15 | elseif self.target_other and message.other then 16 | go.delete(message.other) 17 | elseif self.target_type ~= hash("") then 18 | local objects = lookup.get_objects_by_type(self.target_type) 19 | for _,object in pairs(objects) do 20 | go.delete(object.id) 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /defkit/actions/basic2/draw_score.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("x_var", hash("")) 8 | go.property("x_val", 0) 9 | 10 | go.property("y_var", hash("")) 11 | go.property("y_val", 0) 12 | 13 | function on_message(self, action_id, action, sender) 14 | if sender == self.event then 15 | local score_value = lookup.get_variable(hash("score"), 0) 16 | 17 | local x_value = lookup.get_variable(self.x_var, self.x_val) 18 | local y_value = lookup.get_variable(self.y_var, self.y_val) 19 | 20 | local draw_pos = vmath.vector3(x_value, y_value, 0) 21 | msg.post("@render:", "draw_text", { text = string.format("Score: %d", score_value), position = draw_pos } ) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /defkit/actions/basic2/set_alarm.script: -------------------------------------------------------------------------------- 1 | go.property("event", msg.url()) 2 | 3 | go.property("alarm_nr", 0) 4 | go.property("seconds", 0) 5 | 6 | go.property("anim_param_dont_touch", 0) 7 | 8 | local function invoke_alarm(self, url, property) 9 | msg.post(".", "invoke_alarm", {alarm_nr=self.alarm_nr}) 10 | end 11 | 12 | function on_message(self, message_id, message, sender) 13 | if sender == self.event then 14 | go.animate("#","anim_param_dont_touch", 15 | go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_LINEAR, 16 | self.seconds, 0, 17 | invoke_alarm) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /defkit/actions/basic2/set_score.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | go.property("event", msg.url()) 4 | 5 | go.property("score", 0) 6 | go.property("relative", false) 7 | 8 | function on_message(self, message_id, message, sender) 9 | if sender == self.event then 10 | local value = self.score 11 | if self.relative then 12 | value = value + lookup.get_variable(hash("score"), 0) 13 | end 14 | lookup.set_variable(hash("score"), value) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /defkit/actions/basic2/set_variable.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | go.property("event", msg.url()) 4 | 5 | go.property("name", hash("")) 6 | 7 | go.property("value_val", 0) 8 | go.property("value_var", hash("")) 9 | 10 | go.property("relative", false) 11 | 12 | function on_message(self, message_id, message, sender) 13 | if sender == self.event then 14 | local value = lookup.get_variable(self.value_var, self.value_val) 15 | if self.relative then 16 | value = value + lookup.get_variable(self.name, 0) 17 | end 18 | lookup.set_variable(self.name, value) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /defkit/actions/control/test_chance.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | go.property("event", msg.url()) 4 | 5 | go.property("sides_val", 1) 6 | go.property("sides_var", hash("")) 7 | 8 | function on_message(self, message_id, message, sender) 9 | if sender == self.event then 10 | local sides_count = lookup.get_variable(self.sides_var, self.sides_val) 11 | 12 | local chance = 1 / sides_count 13 | if math.random() <= chance then 14 | msg.post(".", "do_actions") 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /defkit/actions/control/test_instance_count.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | go.property("event", msg.url()) 4 | 5 | go.property("type", hash("")) 6 | 7 | go.property("count_val", 0) 8 | go.property("count_var", hash("")) 9 | 10 | --- Since we don't have enums, use sort value selection. 11 | go.property("comparer", 0) 12 | 13 | function on_message(self, message_id, message, sender) 14 | if sender == self.event then 15 | local compare_count = lookup.get_variable(self.count_var, self.count_val) 16 | local objects = lookup.get_objects_by_type(self.type) 17 | local object_count = 0 18 | for _,_ in pairs(objects) do 19 | object_count = object_count + 1 20 | end 21 | 22 | local match = false 23 | if self.comparer == 0 and object_count == compare_count then 24 | match = true 25 | elseif self.comparer == -1 and object_count < compare_count then 26 | match = true 27 | elseif self.comparer == 1 and object_count > compare_count then 28 | match = true 29 | end 30 | 31 | if match then 32 | msg.post(".", "do_actions") 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /defkit/actions/jump/jump_to_position.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("x_var", hash("")) 8 | go.property("x_val", 0) 9 | 10 | go.property("y_var", hash("")) 11 | go.property("y_val", 0) 12 | 13 | go.property("relative", false) 14 | 15 | --- TARGETTING PROPERTIES 16 | go.property("target_self", false) 17 | go.property("target_other", false) 18 | go.property("target_type", hash("")) 19 | 20 | local function get_position(self) 21 | local x_value = lookup.get_variable(self.x_var, self.x_val) 22 | local y_value = lookup.get_variable(self.y_var, self.y_val) 23 | 24 | local target_pos = vmath.vector3(x_value, y_value, 0) 25 | 26 | return target_pos 27 | end 28 | 29 | function on_message(self, message_id, message, sender) 30 | if sender == self.event then 31 | local position = get_position(self) 32 | if self.target_self then 33 | msg.post(".", "set_position", {position=position, relative=self.relative}) 34 | elseif self.target_other and message.other then 35 | msg.post(message.other, "set_position", {position=position, relative=self.relative}) 36 | elseif self.target_type ~= hash("") then 37 | local objects = lookup.get_objects_by_type(self.target_type) 38 | for _,object in pairs(objects) do 39 | msg.post(object.url, "set_position", {position=position, relative=self.relative}) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /defkit/actions/main1/play_animation.script: -------------------------------------------------------------------------------- 1 | --local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("sprite", msg.url("#sprite")) 8 | go.property("animation_id", hash("")) 9 | 10 | function on_message(self, message_id, message, sender) 11 | if sender == self.event then 12 | msg.post(self.sprite, "play_animation", {id=self.animation_id}) 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /defkit/actions/main1/play_particlefx.script: -------------------------------------------------------------------------------- 1 | --local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("particles", msg.url("#particlefx")) 8 | 9 | function on_message(self, message_id, message, sender) 10 | if sender == self.event then 11 | particlefx.play(self.particles) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /defkit/actions/main1/play_sound.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("sound", msg.url("#sound")) 8 | go.property("delay_val", 0) 9 | go.property("delay_var", hash("")) 10 | go.property("gain_val", 1) 11 | go.property("gain_var", hash("")) 12 | 13 | function on_message(self, message_id, message, sender) 14 | if sender == self.event then 15 | local delay_value = lookup.get_variable(self.delay_var, self.delay_val) 16 | local gain_value = lookup.get_variable(self.gain_var, self.gain_val) 17 | msg.post(self.sound, "play_sound", {delay = delay_value, gain = gain_value}) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /defkit/actions/main1/play_spine.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("spine_model", msg.url("#spine")) 8 | go.property("animation_id", hash("")) 9 | 10 | go.property("playback_once_forward", true) 11 | go.property("playback_once_backward", false) 12 | go.property("playback_once_pingpong", false) 13 | go.property("playback_loop_forward", false) 14 | go.property("playback_loop_backward", false) 15 | go.property("playback_loop_pingpong", false) 16 | 17 | go.property("blend_duration_val", 0) 18 | go.property("blend_duration_var", hash("")) 19 | 20 | 21 | local function get_playback_value(self) 22 | if self.playback_once_forward then 23 | return go.PLAYBACK_ONCE_FORWARD 24 | 25 | elseif self.playback_once_backward then 26 | return go.PLAYBACK_LOOP_FORWARD 27 | 28 | elseif self.playback_once_pingpong then 29 | return go.PLAYBACK_LOOP_FORWARD 30 | 31 | elseif self.playback_loop_forward then 32 | return go.PLAYBACK_LOOP_FORWARD 33 | 34 | elseif self.playback_loop_backward then 35 | return go.PLAYBACK_LOOP_FORWARD 36 | 37 | elseif self.playback_loop_pingpong then 38 | return go.PLAYBACK_LOOP_FORWARD 39 | end 40 | 41 | return go.PLAYBACK_ONCE_FORWARD 42 | end 43 | 44 | function init(self) 45 | self.playback_value = get_playback_value(self) 46 | end 47 | 48 | function on_message(self, message_id, message, sender) 49 | if sender == self.event then 50 | local blend_duration_value = lookup.get_variable(self.blend_duration_var, self.blend_duration_val) 51 | spine.play(self.spine_model, self.animation_id, self.playback_value, blend_duration_value) 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /defkit/actions/main1/set_label_text.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | go.property("event", msg.url()) 4 | 5 | go.property("label", msg.url("#label")) 6 | 7 | go.property("value_val", 0) 8 | go.property("value_var", hash("")) 9 | 10 | function on_message(self, message_id, message, sender) 11 | if sender == self.event then 12 | local text_value = lookup.get_variable(self.value_var, self.value_val) 13 | label.set_text(self.label, tostring(text_value)) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /defkit/actions/move/move_fixed.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("NW", false) 8 | go.property("N", false) 9 | go.property("NE", false) 10 | go.property("W", false) 11 | go.property("E", false) 12 | go.property("SW", false) 13 | go.property("S", false) 14 | go.property("SE", false) 15 | go.property("NONE", false) 16 | 17 | go.property("speed_var", hash("")) 18 | go.property("speed_val", 0) 19 | go.property("relative", false) 20 | 21 | --- TARGETTING PROPERTIES 22 | go.property("target_self", false) 23 | go.property("target_other", false) 24 | go.property("target_type", hash("")) 25 | 26 | function init(self) 27 | local directions = {} 28 | 29 | if self.NW then 30 | table.insert(directions, vmath.vector3(-1, 1, 0)) 31 | end 32 | 33 | if self.N then 34 | table.insert(directions, vmath.vector3(0, 1, 0)) 35 | end 36 | 37 | if self.NE then 38 | table.insert(directions, vmath.vector3(1, 1, 0)) 39 | end 40 | 41 | if self.W then 42 | table.insert(directions, vmath.vector3(-1, 0, 0)) 43 | end 44 | 45 | if self.E then 46 | table.insert(directions, vmath.vector3(1, 0, 0)) 47 | end 48 | 49 | if self.SW then 50 | table.insert(directions, vmath.vector3(-1, -1, 0)) 51 | end 52 | 53 | if self.S then 54 | table.insert(directions, vmath.vector3(0, -1, 0)) 55 | end 56 | 57 | if self.SE then 58 | table.insert(directions, vmath.vector3(1, -1, 0)) 59 | end 60 | 61 | if self.NONE then 62 | table.insert(directions, vmath.vector3(0, 0, 0)) 63 | end 64 | 65 | self.directions = directions 66 | end 67 | 68 | local function get_force(self) 69 | -- random between selected directions. 70 | if next(self.directions) then 71 | local option = math.random(#self.directions) 72 | local direction = self.directions[option] 73 | 74 | local speed_value = lookup.get_variable(self.speed_var, self.speed_val) 75 | return direction * speed_value 76 | else 77 | return vmath.vector3(0) 78 | end 79 | end 80 | 81 | function on_message(self, message_id, message, sender) 82 | if sender == self.event then 83 | local velocity = get_force(self) 84 | if self.target_self then 85 | msg.post(".", "set_movement", {velocity=velocity, relative=self.relative}) 86 | elseif self.target_other and message.other then 87 | msg.post(message.other, "set_movement", {velocity=velocity, relative=self.relative}) 88 | elseif self.target_type ~= hash("") then 89 | local objects = lookup.get_objects_by_type(self.target_type) 90 | for _,object in pairs(objects) do 91 | msg.post(object.url, "set_movement", {velocity=velocity, relative=self.relative}) 92 | end 93 | end 94 | end 95 | end 96 | -------------------------------------------------------------------------------- /defkit/actions/move/move_free.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("direction_var", hash("")) 8 | go.property("direction_val", 0) 9 | 10 | go.property("speed_var", hash("")) 11 | go.property("speed_val", 0) 12 | go.property("relative", false) 13 | 14 | --- TARGETTING PROPERTIES 15 | go.property("target_self", false) 16 | go.property("target_other", false) 17 | go.property("target_type", hash("")) 18 | 19 | local function get_force(self) 20 | local rotation_value = lookup.get_variable(self.direction_var, self.direction_val) 21 | local radians = math.rad(rotation_value) 22 | local direction = vmath.vector3(math.cos(radians), math.sin(radians), 0) 23 | 24 | local speed_value = lookup.get_variable(self.speed_var, self.speed_val) 25 | return direction * speed_value 26 | end 27 | 28 | function on_message(self, message_id, message, sender) 29 | if sender == self.event then 30 | local velocity = get_force(self) 31 | if self.target_self then 32 | msg.post(".", "set_movement", {velocity=velocity, relative=self.relative}) 33 | elseif self.target_other and message.other then 34 | msg.post(message.other, "set_movement", {velocity=velocity, relative=self.relative}) 35 | elseif self.target_type ~= hash("") then 36 | local objects = lookup.get_objects_by_type(self.target_type) 37 | for _,object in pairs(objects) do 38 | msg.post(object.url, "set_movement", {velocity=velocity, relative=self.relative}) 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /defkit/actions/move/move_towards.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("x_var", hash("")) 8 | go.property("x_val", 0) 9 | 10 | go.property("y_var", hash("")) 11 | go.property("y_val", 0) 12 | 13 | go.property("speed_var", hash("")) 14 | go.property("speed_val", 0) 15 | 16 | go.property("relative", false) 17 | 18 | --- TARGETTING PROPERTIES 19 | go.property("target_self", false) 20 | go.property("target_other", false) 21 | go.property("target_type", hash("")) 22 | 23 | local function get_force(self) 24 | local x_value = lookup.get_variable(self.x_var, self.x_val) 25 | local y_value = lookup.get_variable(self.y_var, self.y_val) 26 | 27 | local target_pos = vmath.vector3(x_value, y_value, 0) 28 | 29 | local current_pos = go.get_world_position() 30 | 31 | -- TODO: Given that direction is based on delta, it will be hard to pre-calc this and use set_movement. 32 | local direction = target_pos - current_pos 33 | 34 | local speed_value = lookup.get_variable(self.speed_var, self.speed_val) 35 | return direction * speed_value 36 | end 37 | 38 | function on_message(self, message_id, message, sender) 39 | if sender == self.event then 40 | local velocity = get_force(self) 41 | if self.target_self then 42 | msg.post(".", "set_movement", {velocity=velocity, relative=self.relative}) 43 | elseif self.target_other and message.other then 44 | msg.post(message.other, "set_movement", {velocity=velocity, relative=self.relative}) 45 | elseif self.target_type ~= hash("") then 46 | local objects = lookup.get_objects_by_type(self.target_type) 47 | for _,object in pairs(objects) do 48 | msg.post(object.url, "set_movement", {velocity=velocity, relative=self.relative}) 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /defkit/actions/move/set_gravity.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("direction_var", hash("")) 8 | go.property("direction_val", 0) 9 | 10 | go.property("speed_var", hash("")) 11 | go.property("speed_val", 0) 12 | go.property("relative", false) 13 | 14 | --- TARGETTING PROPERTIES 15 | go.property("target_self", false) 16 | go.property("target_other", false) 17 | go.property("target_type", hash("")) 18 | 19 | local function get_force(self) 20 | local rotation_value = lookup.get_variable(self.direction_var, self.direction_val) 21 | local radians = math.rad(rotation_value) 22 | local direction = vmath.vector3(math.cos(radians), math.sin(radians), 0) 23 | 24 | local speed_value = lookup.get_variable(self.speed_var, self.speed_val) 25 | return direction * speed_value 26 | end 27 | 28 | function on_message(self, message_id, message, sender) 29 | if sender == self.event then 30 | local velocity = get_force(self) 31 | if self.target_self then 32 | msg.post(".", "set_gravity", {velocity=velocity, relative=self.relative}) 33 | elseif self.target_other and message.other then 34 | msg.post(message.other, "set_gravity", {velocity=velocity, relative=self.relative}) 35 | elseif self.target_type ~= hash("") then 36 | local objects = lookup.get_objects_by_type(self.target_type) 37 | for _,object in pairs(objects) do 38 | msg.post(object.url, "set_gravity", {velocity=velocity, relative=self.relative}) 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /defkit/actions/room/go_to_room.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | go.property("number", 0) 8 | 9 | function on_message(self, message_id, message, sender) 10 | if sender == self.event then 11 | msg.post(lookup.get_room_controller(), "go_to", {number=self.number}) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /defkit/actions/room/next_room.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | 8 | function on_message(self, message_id, message, sender) 9 | if sender == self.event then 10 | msg.post(lookup.get_room_controller(), "next") 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /defkit/actions/room/previous_room.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | 8 | function on_message(self, message_id, message, sender) 9 | if sender == self.event then 10 | msg.post(lookup.get_room_controller(), "previous") 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /defkit/actions/room/restart_room.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | --- DEFAULT ACTION PROPERTIES 4 | go.property("event", msg.url()) 5 | 6 | --- CUSTOM ACTION PROPERTIES 7 | 8 | function on_message(self, message_id, message, sender) 9 | if sender == self.event then 10 | msg.post(lookup.get_room_controller(), "restart") 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /defkit/events/contact/on_collision.script: -------------------------------------------------------------------------------- 1 | go.property("collision_group", hash("default")) 2 | 3 | function on_message(self, message_id, message, sender) 4 | if message_id == hash("collision_response") then 5 | if message.group == self.collision_group then 6 | msg.post(".", "do_actions", {other=message.other_id}) 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /defkit/events/input/on_button.script: -------------------------------------------------------------------------------- 1 | go.property("action_id", hash("")) 2 | 3 | function init(self) 4 | msg.post(".", "acquire_input_focus") 5 | end 6 | 7 | function final(self) 8 | msg.post(".", "release_input_focus") 9 | end 10 | 11 | function on_input(self, action_id, action) 12 | if action_id == self.action_id then 13 | msg.post(".", hash("do_actions")) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /defkit/events/input/on_button_press.script: -------------------------------------------------------------------------------- 1 | go.property("action_id", hash("")) 2 | 3 | function init(self) 4 | msg.post(".", "acquire_input_focus") 5 | end 6 | 7 | function final(self) 8 | msg.post(".", "release_input_focus") 9 | end 10 | 11 | function on_input(self, action_id, action) 12 | if action_id == self.action_id and action.pressed then 13 | msg.post(".", hash("do_actions")) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /defkit/events/input/on_button_release.script: -------------------------------------------------------------------------------- 1 | go.property("action_id", hash("")) 2 | 3 | function init(self) 4 | msg.post(".", "acquire_input_focus") 5 | end 6 | 7 | function final(self) 8 | msg.post(".", "release_input_focus") 9 | end 10 | 11 | function on_input(self, action_id, action) 12 | if action_id == self.action_id and action.released then 13 | msg.post(".", hash("do_actions")) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /defkit/events/on_create.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post(".", hash("do_actions")) 3 | end 4 | -------------------------------------------------------------------------------- /defkit/events/on_destroy.script: -------------------------------------------------------------------------------- 1 | function final(self) 2 | msg.post(".", hash("do_actions")) 3 | end 4 | -------------------------------------------------------------------------------- /defkit/events/other/on_animation_end.script: -------------------------------------------------------------------------------- 1 | go.property("animation_id", hash("")) 2 | 3 | function on_message(self, message_id, message, sender) 4 | -- check for animation done response 5 | if message_id == hash("animation_done") then 6 | if message.id == self.animation_id then 7 | msg.post(".", "do_actions") 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /defkit/events/time/on_alarm.script: -------------------------------------------------------------------------------- 1 | go.property("alarm_nr", 0) 2 | 3 | function on_message(self, message_id, message, sender) 4 | if message_id == hash("invoke_alarm") 5 | and message.alarm_nr == self.alarm_nr then 6 | msg.post(".", hash("do_actions")) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /defkit/events/time/on_step.script: -------------------------------------------------------------------------------- 1 | function update(self, dt) 2 | msg.post(".","do_actions") 3 | end -------------------------------------------------------------------------------- /defkit/internal/lookup.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local dynamic_variables = {} 4 | 5 | local objects_by_id = {} 6 | local objects_by_type_id = {} 7 | 8 | local room_controller 9 | 10 | local EMPTY_HASH = hash("") 11 | 12 | function M.add_object_by_type(object_type, game_object_id) 13 | assert(object_type) 14 | assert(game_object_id) 15 | 16 | local object = { 17 | id = game_object_id, 18 | type = object_type, 19 | url = msg.url(), 20 | } 21 | 22 | objects_by_id[game_object_id] = object 23 | 24 | if not objects_by_type_id[object_type] then 25 | objects_by_type_id[object_type] = {} 26 | end 27 | objects_by_type_id[object_type][game_object_id] = object 28 | end 29 | 30 | function M.remove_object(game_object_id) 31 | assert(game_object_id) 32 | assert(objects_by_id[game_object_id], "Unknown game_object_id") 33 | 34 | local object = objects_by_id[game_object_id] 35 | 36 | objects_by_id[game_object_id] = nil 37 | objects_by_type_id[object.type][game_object_id] = nil 38 | end 39 | 40 | function M.get_objects_by_type(object_type) 41 | assert(object_type) 42 | 43 | return objects_by_type_id[object_type] or {} 44 | end 45 | 46 | function M.set_variable(hashed, value) 47 | assert(hashed) 48 | assert(value) 49 | 50 | dynamic_variables[hashed] = value 51 | end 52 | 53 | function M.get_variable(hashed, default_value) 54 | assert(hashed) 55 | 56 | if hashed == EMPTY_HASH then 57 | return default_value 58 | end 59 | 60 | if dynamic_variables[hashed] then 61 | return dynamic_variables[hashed] 62 | elseif not default_value then 63 | error(string.format("Requested unknown variable %s", tostring(hashed))) 64 | end 65 | 66 | return default_value 67 | end 68 | 69 | function M.set_room_controller(url) 70 | assert(url) 71 | room_controller = url 72 | end 73 | 74 | function M.get_room_controller() 75 | return room_controller 76 | end 77 | 78 | return M 79 | -------------------------------------------------------------------------------- /defkit/object.script: -------------------------------------------------------------------------------- 1 | local lookup = require("defkit.internal.lookup") 2 | 3 | go.property("type", hash("unknown")) 4 | 5 | function init(self) 6 | lookup.add_object_by_type(self.type, go.get_id()) 7 | 8 | self.velocity = vmath.vector3(0) 9 | end 10 | 11 | function final(self) 12 | lookup.remove_object(go.get_id()) 13 | end 14 | 15 | function update(self, dt) 16 | if self.gravity and vmath.length_sqr(self.gravity) > 0.01 then 17 | self.velocity = self.velocity + self.gravity * dt 18 | end 19 | 20 | if vmath.length_sqr(self.velocity) > 0.01 then 21 | local pos = go.get_position() 22 | pos = pos + self.velocity * dt 23 | go.set_position(pos) 24 | end 25 | end 26 | 27 | function on_message(self, message_id, message, sender) 28 | if message_id == hash("set_movement") then 29 | if message.relative then 30 | self.velocity = message.velocity + self.velocity 31 | else 32 | self.velocity = message.velocity 33 | end 34 | elseif message_id == hash("set_position") then 35 | local new_pos = message.position 36 | if message.relative then 37 | new_pos = new_pos + go.get_position() 38 | end 39 | go.set_position(new_pos) 40 | elseif message_id == hash("set_gravity") then 41 | local gravity = message.velocity 42 | if message.relative and self.gravity then 43 | self.gravity = self.gravity + gravity 44 | else 45 | self.gravity = gravity 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /defkit/rooms.script: -------------------------------------------------------------------------------- 1 | local lookup = require "defkit.internal.lookup" 2 | 3 | local function load(id) 4 | msg.post("#room"..id, "load") 5 | end 6 | 7 | local function unload(id) 8 | msg.post("#room"..id, "unload") 9 | end 10 | 11 | function init(self) 12 | lookup.set_room_controller(msg.url()) 13 | 14 | msg.post(".", "acquire_input_focus") 15 | 16 | self.current = 0 17 | load(self.current) 18 | end 19 | 20 | function on_message(self, message_id, message, sender) 21 | if message_id == hash("proxy_loaded") then 22 | msg.post(sender, "enable") 23 | 24 | elseif message_id == hash("proxy_unloaded") then 25 | if self.restart then 26 | load(self.current) 27 | self.restart = false 28 | end 29 | 30 | elseif message_id == hash("restart") then 31 | self.restart = true 32 | unload(self.current) 33 | 34 | elseif message_id == hash("next") then 35 | unload(self.current) 36 | self.current = self.current +1 37 | load(self.current) 38 | 39 | elseif message_id == hash("previous") then 40 | assert(self.current > 0, "You can not navigate further backwards") 41 | 42 | unload(self.current) 43 | self.current = self.current -1 44 | load(self.current) 45 | 46 | elseif message_id == hash("go_to") then 47 | assert(message.number) 48 | assert(message.number >= 0, "Room number can not be negative") 49 | 50 | unload(self.current) 51 | self.current = message.number 52 | load(self.current) 53 | end 54 | 55 | end 56 | -------------------------------------------------------------------------------- /examples/rooms/room0.collection: -------------------------------------------------------------------------------- 1 | name: "room0" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"next_room\"\n" 7 | " component: \"/defkit/actions/room/next_room.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | " properties {\n" 20 | " id: \"event\"\n" 21 | " value: \"#on_button_right\"\n" 22 | " type: PROPERTY_TYPE_URL\n" 23 | " }\n" 24 | "}\n" 25 | "components {\n" 26 | " id: \"on_button_right\"\n" 27 | " component: \"/defkit/events/input/on_button_release.script\"\n" 28 | " position {\n" 29 | " x: 0.0\n" 30 | " y: 0.0\n" 31 | " z: 0.0\n" 32 | " }\n" 33 | " rotation {\n" 34 | " x: 0.0\n" 35 | " y: 0.0\n" 36 | " z: 0.0\n" 37 | " w: 1.0\n" 38 | " }\n" 39 | " properties {\n" 40 | " id: \"action_id\"\n" 41 | " value: \"right\"\n" 42 | " type: PROPERTY_TYPE_HASH\n" 43 | " }\n" 44 | "}\n" 45 | "embedded_components {\n" 46 | " id: \"label\"\n" 47 | " type: \"label\"\n" 48 | " data: \"size {\\n" 49 | " x: 128.0\\n" 50 | " y: 32.0\\n" 51 | " z: 0.0\\n" 52 | " w: 0.0\\n" 53 | "}\\n" 54 | "scale {\\n" 55 | " x: 1.0\\n" 56 | " y: 1.0\\n" 57 | " z: 1.0\\n" 58 | " w: 0.0\\n" 59 | "}\\n" 60 | "color {\\n" 61 | " x: 1.0\\n" 62 | " y: 1.0\\n" 63 | " z: 1.0\\n" 64 | " w: 1.0\\n" 65 | "}\\n" 66 | "outline {\\n" 67 | " x: 0.0\\n" 68 | " y: 0.0\\n" 69 | " z: 0.0\\n" 70 | " w: 1.0\\n" 71 | "}\\n" 72 | "shadow {\\n" 73 | " x: 0.0\\n" 74 | " y: 0.0\\n" 75 | " z: 0.0\\n" 76 | " w: 1.0\\n" 77 | "}\\n" 78 | "leading: 1.0\\n" 79 | "tracking: 0.0\\n" 80 | "pivot: PIVOT_W\\n" 81 | "blend_mode: BLEND_MODE_ALPHA\\n" 82 | "line_break: false\\n" 83 | "text: \\\"Room0\\\\n" 84 | "\\\"\\n" 85 | " \\\"- Right to go Forward\\\"\\n" 86 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 87 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 88 | "\"\n" 89 | " position {\n" 90 | " x: 0.0\n" 91 | " y: 0.0\n" 92 | " z: 0.0\n" 93 | " }\n" 94 | " rotation {\n" 95 | " x: 0.0\n" 96 | " y: 0.0\n" 97 | " z: 0.0\n" 98 | " w: 1.0\n" 99 | " }\n" 100 | "}\n" 101 | "" 102 | position { 103 | x: 100.0 104 | y: 100.0 105 | z: 0.0 106 | } 107 | rotation { 108 | x: 0.0 109 | y: 0.0 110 | z: 0.0 111 | w: 1.0 112 | } 113 | scale3 { 114 | x: 1.0 115 | y: 1.0 116 | z: 1.0 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /examples/rooms/room1.collection: -------------------------------------------------------------------------------- 1 | name: "room1" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"previous_room\"\n" 7 | " component: \"/defkit/actions/room/previous_room.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | " properties {\n" 20 | " id: \"event\"\n" 21 | " value: \"#on_button_left\"\n" 22 | " type: PROPERTY_TYPE_URL\n" 23 | " }\n" 24 | "}\n" 25 | "components {\n" 26 | " id: \"on_button_left\"\n" 27 | " component: \"/defkit/events/input/on_button_release.script\"\n" 28 | " position {\n" 29 | " x: 0.0\n" 30 | " y: 0.0\n" 31 | " z: 0.0\n" 32 | " }\n" 33 | " rotation {\n" 34 | " x: 0.0\n" 35 | " y: 0.0\n" 36 | " z: 0.0\n" 37 | " w: 1.0\n" 38 | " }\n" 39 | " properties {\n" 40 | " id: \"action_id\"\n" 41 | " value: \"left\"\n" 42 | " type: PROPERTY_TYPE_HASH\n" 43 | " }\n" 44 | "}\n" 45 | "components {\n" 46 | " id: \"next_room\"\n" 47 | " component: \"/defkit/actions/room/next_room.script\"\n" 48 | " position {\n" 49 | " x: 0.0\n" 50 | " y: 0.0\n" 51 | " z: 0.0\n" 52 | " }\n" 53 | " rotation {\n" 54 | " x: 0.0\n" 55 | " y: 0.0\n" 56 | " z: 0.0\n" 57 | " w: 1.0\n" 58 | " }\n" 59 | " properties {\n" 60 | " id: \"event\"\n" 61 | " value: \"#on_button_right\"\n" 62 | " type: PROPERTY_TYPE_URL\n" 63 | " }\n" 64 | "}\n" 65 | "components {\n" 66 | " id: \"on_button_right\"\n" 67 | " component: \"/defkit/events/input/on_button_release.script\"\n" 68 | " position {\n" 69 | " x: 0.0\n" 70 | " y: 0.0\n" 71 | " z: 0.0\n" 72 | " }\n" 73 | " rotation {\n" 74 | " x: 0.0\n" 75 | " y: 0.0\n" 76 | " z: 0.0\n" 77 | " w: 1.0\n" 78 | " }\n" 79 | " properties {\n" 80 | " id: \"action_id\"\n" 81 | " value: \"right\"\n" 82 | " type: PROPERTY_TYPE_HASH\n" 83 | " }\n" 84 | "}\n" 85 | "embedded_components {\n" 86 | " id: \"label\"\n" 87 | " type: \"label\"\n" 88 | " data: \"size {\\n" 89 | " x: 128.0\\n" 90 | " y: 32.0\\n" 91 | " z: 0.0\\n" 92 | " w: 0.0\\n" 93 | "}\\n" 94 | "scale {\\n" 95 | " x: 1.0\\n" 96 | " y: 1.0\\n" 97 | " z: 1.0\\n" 98 | " w: 0.0\\n" 99 | "}\\n" 100 | "color {\\n" 101 | " x: 1.0\\n" 102 | " y: 1.0\\n" 103 | " z: 1.0\\n" 104 | " w: 1.0\\n" 105 | "}\\n" 106 | "outline {\\n" 107 | " x: 0.0\\n" 108 | " y: 0.0\\n" 109 | " z: 0.0\\n" 110 | " w: 1.0\\n" 111 | "}\\n" 112 | "shadow {\\n" 113 | " x: 0.0\\n" 114 | " y: 0.0\\n" 115 | " z: 0.0\\n" 116 | " w: 1.0\\n" 117 | "}\\n" 118 | "leading: 1.0\\n" 119 | "tracking: 0.0\\n" 120 | "pivot: PIVOT_W\\n" 121 | "blend_mode: BLEND_MODE_ALPHA\\n" 122 | "line_break: false\\n" 123 | "text: \\\"Room1\\\\n" 124 | "\\\"\\n" 125 | " \\\"- Left to go Back\\\\n" 126 | "\\\"\\n" 127 | " \\\"- Right to go Forward\\\"\\n" 128 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 129 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 130 | "\"\n" 131 | " position {\n" 132 | " x: 0.0\n" 133 | " y: 0.0\n" 134 | " z: 0.0\n" 135 | " }\n" 136 | " rotation {\n" 137 | " x: 0.0\n" 138 | " y: 0.0\n" 139 | " z: 0.0\n" 140 | " w: 1.0\n" 141 | " }\n" 142 | "}\n" 143 | "" 144 | position { 145 | x: 100.0 146 | y: 100.0 147 | z: 0.0 148 | } 149 | rotation { 150 | x: 0.0 151 | y: 0.0 152 | z: 0.0 153 | w: 1.0 154 | } 155 | scale3 { 156 | x: 1.0 157 | y: 1.0 158 | z: 1.0 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /examples/rooms/room2.collection: -------------------------------------------------------------------------------- 1 | name: "room2" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"restart_room\"\n" 7 | " component: \"/defkit/actions/room/restart_room.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | " properties {\n" 20 | " id: \"event\"\n" 21 | " value: \"#on_button_space\"\n" 22 | " type: PROPERTY_TYPE_URL\n" 23 | " }\n" 24 | "}\n" 25 | "components {\n" 26 | " id: \"on_button_left\"\n" 27 | " component: \"/defkit/events/input/on_button_release.script\"\n" 28 | " position {\n" 29 | " x: 0.0\n" 30 | " y: 0.0\n" 31 | " z: 0.0\n" 32 | " }\n" 33 | " rotation {\n" 34 | " x: 0.0\n" 35 | " y: 0.0\n" 36 | " z: 0.0\n" 37 | " w: 1.0\n" 38 | " }\n" 39 | " properties {\n" 40 | " id: \"action_id\"\n" 41 | " value: \"left\"\n" 42 | " type: PROPERTY_TYPE_HASH\n" 43 | " }\n" 44 | "}\n" 45 | "components {\n" 46 | " id: \"on_button_space\"\n" 47 | " component: \"/defkit/events/input/on_button_release.script\"\n" 48 | " position {\n" 49 | " x: 0.0\n" 50 | " y: 0.0\n" 51 | " z: 0.0\n" 52 | " }\n" 53 | " rotation {\n" 54 | " x: 0.0\n" 55 | " y: 0.0\n" 56 | " z: 0.0\n" 57 | " w: 1.0\n" 58 | " }\n" 59 | " properties {\n" 60 | " id: \"action_id\"\n" 61 | " value: \"space\"\n" 62 | " type: PROPERTY_TYPE_HASH\n" 63 | " }\n" 64 | "}\n" 65 | "components {\n" 66 | " id: \"go_to_room0\"\n" 67 | " component: \"/defkit/actions/room/go_to_room.script\"\n" 68 | " position {\n" 69 | " x: 0.0\n" 70 | " y: 0.0\n" 71 | " z: 0.0\n" 72 | " }\n" 73 | " rotation {\n" 74 | " x: 0.0\n" 75 | " y: 0.0\n" 76 | " z: 0.0\n" 77 | " w: 1.0\n" 78 | " }\n" 79 | " properties {\n" 80 | " id: \"event\"\n" 81 | " value: \"#on_button_right\"\n" 82 | " type: PROPERTY_TYPE_URL\n" 83 | " }\n" 84 | "}\n" 85 | "components {\n" 86 | " id: \"on_button_right\"\n" 87 | " component: \"/defkit/events/input/on_button_release.script\"\n" 88 | " position {\n" 89 | " x: 0.0\n" 90 | " y: 0.0\n" 91 | " z: 0.0\n" 92 | " }\n" 93 | " rotation {\n" 94 | " x: 0.0\n" 95 | " y: 0.0\n" 96 | " z: 0.0\n" 97 | " w: 1.0\n" 98 | " }\n" 99 | " properties {\n" 100 | " id: \"action_id\"\n" 101 | " value: \"right\"\n" 102 | " type: PROPERTY_TYPE_HASH\n" 103 | " }\n" 104 | "}\n" 105 | "components {\n" 106 | " id: \"previous_room\"\n" 107 | " component: \"/defkit/actions/room/previous_room.script\"\n" 108 | " position {\n" 109 | " x: 0.0\n" 110 | " y: 0.0\n" 111 | " z: 0.0\n" 112 | " }\n" 113 | " rotation {\n" 114 | " x: 0.0\n" 115 | " y: 0.0\n" 116 | " z: 0.0\n" 117 | " w: 1.0\n" 118 | " }\n" 119 | " properties {\n" 120 | " id: \"event\"\n" 121 | " value: \"#on_button_left\"\n" 122 | " type: PROPERTY_TYPE_URL\n" 123 | " }\n" 124 | "}\n" 125 | "embedded_components {\n" 126 | " id: \"label\"\n" 127 | " type: \"label\"\n" 128 | " data: \"size {\\n" 129 | " x: 128.0\\n" 130 | " y: 32.0\\n" 131 | " z: 0.0\\n" 132 | " w: 0.0\\n" 133 | "}\\n" 134 | "scale {\\n" 135 | " x: 1.0\\n" 136 | " y: 1.0\\n" 137 | " z: 1.0\\n" 138 | " w: 0.0\\n" 139 | "}\\n" 140 | "color {\\n" 141 | " x: 1.0\\n" 142 | " y: 1.0\\n" 143 | " z: 1.0\\n" 144 | " w: 1.0\\n" 145 | "}\\n" 146 | "outline {\\n" 147 | " x: 0.0\\n" 148 | " y: 0.0\\n" 149 | " z: 0.0\\n" 150 | " w: 1.0\\n" 151 | "}\\n" 152 | "shadow {\\n" 153 | " x: 0.0\\n" 154 | " y: 0.0\\n" 155 | " z: 0.0\\n" 156 | " w: 1.0\\n" 157 | "}\\n" 158 | "leading: 1.0\\n" 159 | "tracking: 0.0\\n" 160 | "pivot: PIVOT_W\\n" 161 | "blend_mode: BLEND_MODE_ALPHA\\n" 162 | "line_break: false\\n" 163 | "text: \\\"Room2\\\\n" 164 | "\\\"\\n" 165 | " \\\"- Left to go Back\\\\n" 166 | "\\\"\\n" 167 | " \\\"- Right to room0\\\\n" 168 | "\\\"\\n" 169 | " \\\"- Space to Restart\\\\n" 170 | "\\\"\\n" 171 | " \\\"\\\\n" 172 | "\\\"\\n" 173 | " \\\"\\\"\\n" 174 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 175 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 176 | "\"\n" 177 | " position {\n" 178 | " x: 0.0\n" 179 | " y: 0.0\n" 180 | " z: 0.0\n" 181 | " }\n" 182 | " rotation {\n" 183 | " x: 0.0\n" 184 | " y: 0.0\n" 185 | " z: 0.0\n" 186 | " w: 1.0\n" 187 | " }\n" 188 | "}\n" 189 | "" 190 | position { 191 | x: 100.0 192 | y: 100.0 193 | z: 0.0 194 | } 195 | rotation { 196 | x: 0.0 197 | y: 0.0 198 | z: 0.0 199 | w: 1.0 200 | } 201 | scale3 { 202 | x: 1.0 203 | y: 1.0 204 | z: 1.0 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /examples/rooms/rooms.collection: -------------------------------------------------------------------------------- 1 | name: "rooms" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"rooms\"\n" 7 | " component: \"/defkit/rooms.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "embedded_components {\n" 21 | " id: \"room0\"\n" 22 | " type: \"collectionproxy\"\n" 23 | " data: \"collection: \\\"/examples/rooms/room0.collection\\\"\\n" 24 | "exclude: false\\n" 25 | "\"\n" 26 | " position {\n" 27 | " x: 0.0\n" 28 | " y: 0.0\n" 29 | " z: 0.0\n" 30 | " }\n" 31 | " rotation {\n" 32 | " x: 0.0\n" 33 | " y: 0.0\n" 34 | " z: 0.0\n" 35 | " w: 1.0\n" 36 | " }\n" 37 | "}\n" 38 | "embedded_components {\n" 39 | " id: \"room1\"\n" 40 | " type: \"collectionproxy\"\n" 41 | " data: \"collection: \\\"/examples/rooms/room1.collection\\\"\\n" 42 | "exclude: false\\n" 43 | "\"\n" 44 | " position {\n" 45 | " x: 0.0\n" 46 | " y: 0.0\n" 47 | " z: 0.0\n" 48 | " }\n" 49 | " rotation {\n" 50 | " x: 0.0\n" 51 | " y: 0.0\n" 52 | " z: 0.0\n" 53 | " w: 1.0\n" 54 | " }\n" 55 | "}\n" 56 | "embedded_components {\n" 57 | " id: \"room2\"\n" 58 | " type: \"collectionproxy\"\n" 59 | " data: \"collection: \\\"/examples/rooms/room2.collection\\\"\\n" 60 | "exclude: false\\n" 61 | "\"\n" 62 | " position {\n" 63 | " x: 0.0\n" 64 | " y: 0.0\n" 65 | " z: 0.0\n" 66 | " }\n" 67 | " rotation {\n" 68 | " x: 0.0\n" 69 | " y: 0.0\n" 70 | " z: 0.0\n" 71 | " w: 1.0\n" 72 | " }\n" 73 | "}\n" 74 | "" 75 | position { 76 | x: 0.0 77 | y: 0.0 78 | z: 0.0 79 | } 80 | rotation { 81 | x: 0.0 82 | y: 0.0 83 | z: 0.0 84 | w: 1.0 85 | } 86 | scale3 { 87 | x: 1.0 88 | y: 1.0 89 | z: 1.0 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = DefKit 3 | version = 0.1 4 | 5 | [bootstrap] 6 | main_collection = /main/main.collectionc 7 | 8 | [input] 9 | game_binding = /input/game.input_bindingc 10 | 11 | [display] 12 | width = 1280 13 | height = 720 14 | 15 | [physics] 16 | scale = 0.02 17 | 18 | [script] 19 | shared_state = 1 20 | 21 | [library] 22 | include_dirs = defkit 23 | 24 | -------------------------------------------------------------------------------- /input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_SPACE 3 | action: "space" 4 | } 5 | key_trigger { 6 | input: KEY_UP 7 | action: "up" 8 | } 9 | key_trigger { 10 | input: KEY_DOWN 11 | action: "down" 12 | } 13 | key_trigger { 14 | input: KEY_LEFT 15 | action: "left" 16 | } 17 | key_trigger { 18 | input: KEY_RIGHT 19 | action: "right" 20 | } 21 | -------------------------------------------------------------------------------- /main/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamwestman/defkit/63dc88dcffb6cb676ab13201aaac147d41a6aa2f/main/images/logo.png -------------------------------------------------------------------------------- /main/logo.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/main/images/logo.png" 3 | } 4 | margin: 0 5 | extrude_borders: 1 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /main/main.collection: -------------------------------------------------------------------------------- 1 | name: "main" 2 | instances { 3 | id: "music" 4 | prototype: "/main/music.go" 5 | position { 6 | x: 640.0 7 | y: 400.0 8 | z: 0.1 9 | } 10 | rotation { 11 | x: 0.0 12 | y: 0.0 13 | z: 0.0 14 | w: 1.0 15 | } 16 | scale3 { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | } 21 | } 22 | instances { 23 | id: "player" 24 | prototype: "/main/player.go" 25 | position { 26 | x: 640.0 27 | y: 400.0 28 | z: 0.1 29 | } 30 | rotation { 31 | x: 0.0 32 | y: 0.0 33 | z: 0.0 34 | w: 1.0 35 | } 36 | component_properties { 37 | id: "draw_score" 38 | properties { 39 | id: "x_val" 40 | value: "50.0" 41 | type: PROPERTY_TYPE_NUMBER 42 | } 43 | properties { 44 | id: "y_val" 45 | value: "700.0" 46 | type: PROPERTY_TYPE_NUMBER 47 | } 48 | } 49 | scale3 { 50 | x: 1.0 51 | y: 1.0 52 | z: 1.0 53 | } 54 | } 55 | instances { 56 | id: "point1" 57 | prototype: "/main/point.go" 58 | position { 59 | x: 1000.0 60 | y: 600.0 61 | z: 0.1 62 | } 63 | rotation { 64 | x: 0.0 65 | y: 0.0 66 | z: 0.0 67 | w: 1.0 68 | } 69 | scale3 { 70 | x: 1.0 71 | y: 1.0 72 | z: 1.0 73 | } 74 | } 75 | instances { 76 | id: "point2" 77 | prototype: "/main/point.go" 78 | position { 79 | x: 1000.0 80 | y: 200.0 81 | z: 0.1 82 | } 83 | rotation { 84 | x: 0.0 85 | y: 0.0 86 | z: 0.0 87 | w: 1.0 88 | } 89 | scale3 { 90 | x: 1.0 91 | y: 1.0 92 | z: 1.0 93 | } 94 | } 95 | instances { 96 | id: "point3" 97 | prototype: "/main/point.go" 98 | position { 99 | x: 280.0 100 | y: 600.0 101 | z: 0.1 102 | } 103 | rotation { 104 | x: 0.0 105 | y: 0.0 106 | z: 0.0 107 | w: 1.0 108 | } 109 | scale3 { 110 | x: 1.0 111 | y: 1.0 112 | z: 1.0 113 | } 114 | } 115 | instances { 116 | id: "point4" 117 | prototype: "/main/point.go" 118 | position { 119 | x: 280.0 120 | y: 200.0 121 | z: 0.1 122 | } 123 | rotation { 124 | x: 0.0 125 | y: 0.0 126 | z: 0.0 127 | w: 1.0 128 | } 129 | scale3 { 130 | x: 1.0 131 | y: 1.0 132 | z: 1.0 133 | } 134 | } 135 | instances { 136 | id: "point5" 137 | prototype: "/main/point.go" 138 | position { 139 | x: 640.0 140 | y: 600.0 141 | z: 0.1 142 | } 143 | rotation { 144 | x: 0.0 145 | y: 0.0 146 | z: 0.0 147 | w: 1.0 148 | } 149 | scale3 { 150 | x: 1.0 151 | y: 1.0 152 | z: 1.0 153 | } 154 | } 155 | scale_along_z: 0 156 | embedded_instances { 157 | id: "drop" 158 | data: "components {\n" 159 | " id: \"object\"\n" 160 | " component: \"/defkit/object.script\"\n" 161 | " position {\n" 162 | " x: 0.0\n" 163 | " y: 0.0\n" 164 | " z: 0.0\n" 165 | " }\n" 166 | " rotation {\n" 167 | " x: 0.0\n" 168 | " y: 0.0\n" 169 | " z: 0.0\n" 170 | " w: 1.0\n" 171 | " }\n" 172 | " properties {\n" 173 | " id: \"type\"\n" 174 | " value: \"drop\"\n" 175 | " type: PROPERTY_TYPE_HASH\n" 176 | " }\n" 177 | "}\n" 178 | "components {\n" 179 | " id: \"on_create\"\n" 180 | " component: \"/defkit/events/on_create.script\"\n" 181 | " position {\n" 182 | " x: 0.0\n" 183 | " y: 0.0\n" 184 | " z: 0.0\n" 185 | " }\n" 186 | " rotation {\n" 187 | " x: 0.0\n" 188 | " y: 0.0\n" 189 | " z: 0.0\n" 190 | " w: 1.0\n" 191 | " }\n" 192 | "}\n" 193 | "components {\n" 194 | " id: \"set_gravity\"\n" 195 | " component: \"/defkit/actions/move/set_gravity.script\"\n" 196 | " position {\n" 197 | " x: 0.0\n" 198 | " y: 0.0\n" 199 | " z: 0.0\n" 200 | " }\n" 201 | " rotation {\n" 202 | " x: 0.0\n" 203 | " y: 0.0\n" 204 | " z: 0.0\n" 205 | " w: 1.0\n" 206 | " }\n" 207 | " properties {\n" 208 | " id: \"event\"\n" 209 | " value: \"#on_create\"\n" 210 | " type: PROPERTY_TYPE_URL\n" 211 | " }\n" 212 | " properties {\n" 213 | " id: \"direction_val\"\n" 214 | " value: \"270.0\"\n" 215 | " type: PROPERTY_TYPE_NUMBER\n" 216 | " }\n" 217 | " properties {\n" 218 | " id: \"speed_val\"\n" 219 | " value: \"9.82\"\n" 220 | " type: PROPERTY_TYPE_NUMBER\n" 221 | " }\n" 222 | " properties {\n" 223 | " id: \"target_self\"\n" 224 | " value: \"true\"\n" 225 | " type: PROPERTY_TYPE_BOOLEAN\n" 226 | " }\n" 227 | "}\n" 228 | "embedded_components {\n" 229 | " id: \"sprite\"\n" 230 | " type: \"sprite\"\n" 231 | " data: \"tile_set: \\\"/builtins/graphics/particle_blob.tilesource\\\"\\n" 232 | "default_animation: \\\"anim\\\"\\n" 233 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 234 | "blend_mode: BLEND_MODE_ADD\\n" 235 | "\"\n" 236 | " position {\n" 237 | " x: 158.64465\n" 238 | " y: 162.75282\n" 239 | " z: 0.0\n" 240 | " }\n" 241 | " rotation {\n" 242 | " x: 0.0\n" 243 | " y: 0.0\n" 244 | " z: 0.0\n" 245 | " w: 1.0\n" 246 | " }\n" 247 | "}\n" 248 | "" 249 | position { 250 | x: 640.0 251 | y: 530.44574 252 | z: 0.2 253 | } 254 | rotation { 255 | x: 0.0 256 | y: 0.0 257 | z: 0.0 258 | w: 1.0 259 | } 260 | scale3 { 261 | x: 1.0 262 | y: 1.0 263 | z: 1.0 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /main/music.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "on_create" 3 | component: "/defkit/events/on_create.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | components { 17 | id: "play_sound" 18 | component: "/defkit/actions/main1/play_sound.script" 19 | position { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | } 24 | rotation { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | w: 1.0 29 | } 30 | properties { 31 | id: "event" 32 | value: "#on_create" 33 | type: PROPERTY_TYPE_URL 34 | } 35 | properties { 36 | id: "delay_val" 37 | value: "1.0" 38 | type: PROPERTY_TYPE_NUMBER 39 | } 40 | properties { 41 | id: "gain_val" 42 | value: "0.5" 43 | type: PROPERTY_TYPE_NUMBER 44 | } 45 | properties { 46 | id: "gain_var" 47 | value: "score" 48 | type: PROPERTY_TYPE_HASH 49 | } 50 | } 51 | embedded_components { 52 | id: "sound" 53 | type: "sound" 54 | data: "sound: \"/main/sounds/strings2.wav\"\n" 55 | "looping: 1\n" 56 | "group: \"master\"\n" 57 | "gain: 1.0\n" 58 | "" 59 | position { 60 | x: 0.0 61 | y: 0.0 62 | z: 0.0 63 | } 64 | rotation { 65 | x: 0.0 66 | y: 0.0 67 | z: 0.0 68 | w: 1.0 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /main/player.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "destroy_point" 3 | component: "/defkit/actions/basic/destroy.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | properties { 16 | id: "event" 17 | value: "#on_point_collision" 18 | type: PROPERTY_TYPE_URL 19 | } 20 | properties { 21 | id: "target_type" 22 | value: "point" 23 | type: PROPERTY_TYPE_HASH 24 | } 25 | } 26 | components { 27 | id: "draw_score" 28 | component: "/defkit/actions/basic2/draw_score.script" 29 | position { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | } 34 | rotation { 35 | x: 0.0 36 | y: 0.0 37 | z: 0.0 38 | w: 1.0 39 | } 40 | properties { 41 | id: "event" 42 | value: "#on_step" 43 | type: PROPERTY_TYPE_URL 44 | } 45 | } 46 | components { 47 | id: "move_down" 48 | component: "/defkit/actions/move/move_fixed.script" 49 | position { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | } 54 | rotation { 55 | x: 0.0 56 | y: 0.0 57 | z: 0.0 58 | w: 1.0 59 | } 60 | properties { 61 | id: "event" 62 | value: "#on_down_pressed" 63 | type: PROPERTY_TYPE_URL 64 | } 65 | properties { 66 | id: "S" 67 | value: "true" 68 | type: PROPERTY_TYPE_BOOLEAN 69 | } 70 | properties { 71 | id: "speed_val" 72 | value: "100.0" 73 | type: PROPERTY_TYPE_NUMBER 74 | } 75 | properties { 76 | id: "target_self" 77 | value: "true" 78 | type: PROPERTY_TYPE_BOOLEAN 79 | } 80 | } 81 | components { 82 | id: "move_left" 83 | component: "/defkit/actions/move/move_fixed.script" 84 | position { 85 | x: 0.0 86 | y: 0.0 87 | z: 0.0 88 | } 89 | rotation { 90 | x: 0.0 91 | y: 0.0 92 | z: 0.0 93 | w: 1.0 94 | } 95 | properties { 96 | id: "event" 97 | value: "#on_left_pressed" 98 | type: PROPERTY_TYPE_URL 99 | } 100 | properties { 101 | id: "W" 102 | value: "true" 103 | type: PROPERTY_TYPE_BOOLEAN 104 | } 105 | properties { 106 | id: "speed_val" 107 | value: "100.0" 108 | type: PROPERTY_TYPE_NUMBER 109 | } 110 | properties { 111 | id: "target_self" 112 | value: "true" 113 | type: PROPERTY_TYPE_BOOLEAN 114 | } 115 | } 116 | components { 117 | id: "move_right" 118 | component: "/defkit/actions/move/move_fixed.script" 119 | position { 120 | x: 0.0 121 | y: 0.0 122 | z: 0.0 123 | } 124 | rotation { 125 | x: 0.0 126 | y: 0.0 127 | z: 0.0 128 | w: 1.0 129 | } 130 | properties { 131 | id: "event" 132 | value: "#on_right_pressed" 133 | type: PROPERTY_TYPE_URL 134 | } 135 | properties { 136 | id: "E" 137 | value: "true" 138 | type: PROPERTY_TYPE_BOOLEAN 139 | } 140 | properties { 141 | id: "speed_val" 142 | value: "100.0" 143 | type: PROPERTY_TYPE_NUMBER 144 | } 145 | properties { 146 | id: "target_self" 147 | value: "true" 148 | type: PROPERTY_TYPE_BOOLEAN 149 | } 150 | } 151 | components { 152 | id: "move_up" 153 | component: "/defkit/actions/move/move_fixed.script" 154 | position { 155 | x: 0.0 156 | y: 0.0 157 | z: 0.0 158 | } 159 | rotation { 160 | x: 0.0 161 | y: 0.0 162 | z: 0.0 163 | w: 1.0 164 | } 165 | properties { 166 | id: "event" 167 | value: "#on_up_pressed" 168 | type: PROPERTY_TYPE_URL 169 | } 170 | properties { 171 | id: "N" 172 | value: "true" 173 | type: PROPERTY_TYPE_BOOLEAN 174 | } 175 | properties { 176 | id: "speed_val" 177 | value: "100.0" 178 | type: PROPERTY_TYPE_NUMBER 179 | } 180 | properties { 181 | id: "target_self" 182 | value: "true" 183 | type: PROPERTY_TYPE_BOOLEAN 184 | } 185 | } 186 | components { 187 | id: "obj1" 188 | component: "/defkit/object.script" 189 | position { 190 | x: 0.0 191 | y: 0.0 192 | z: 0.0 193 | } 194 | rotation { 195 | x: 0.0 196 | y: 0.0 197 | z: 0.0 198 | w: 1.0 199 | } 200 | properties { 201 | id: "type" 202 | value: "player" 203 | type: PROPERTY_TYPE_HASH 204 | } 205 | } 206 | components { 207 | id: "on_down_pressed" 208 | component: "/defkit/events/input/on_button_press.script" 209 | position { 210 | x: 0.0 211 | y: 0.0 212 | z: 0.0 213 | } 214 | rotation { 215 | x: 0.0 216 | y: 0.0 217 | z: 0.0 218 | w: 1.0 219 | } 220 | properties { 221 | id: "action_id" 222 | value: "down" 223 | type: PROPERTY_TYPE_HASH 224 | } 225 | } 226 | components { 227 | id: "on_left_pressed" 228 | component: "/defkit/events/input/on_button_press.script" 229 | position { 230 | x: 0.0 231 | y: 0.0 232 | z: 0.0 233 | } 234 | rotation { 235 | x: 0.0 236 | y: 0.0 237 | z: 0.0 238 | w: 1.0 239 | } 240 | properties { 241 | id: "action_id" 242 | value: "left" 243 | type: PROPERTY_TYPE_HASH 244 | } 245 | } 246 | components { 247 | id: "on_point_collision" 248 | component: "/defkit/events/contact/on_collision.script" 249 | position { 250 | x: 0.0 251 | y: 0.0 252 | z: 0.0 253 | } 254 | rotation { 255 | x: 0.0 256 | y: 0.0 257 | z: 0.0 258 | w: 1.0 259 | } 260 | properties { 261 | id: "collision_group" 262 | value: "point" 263 | type: PROPERTY_TYPE_HASH 264 | } 265 | } 266 | components { 267 | id: "on_right_pressed" 268 | component: "/defkit/events/input/on_button_press.script" 269 | position { 270 | x: 0.0 271 | y: 0.0 272 | z: 0.0 273 | } 274 | rotation { 275 | x: 0.0 276 | y: 0.0 277 | z: 0.0 278 | w: 1.0 279 | } 280 | properties { 281 | id: "action_id" 282 | value: "right" 283 | type: PROPERTY_TYPE_HASH 284 | } 285 | } 286 | components { 287 | id: "on_step" 288 | component: "/defkit/events/time/on_step.script" 289 | position { 290 | x: 0.0 291 | y: 0.0 292 | z: 0.0 293 | } 294 | rotation { 295 | x: 0.0 296 | y: 0.0 297 | z: 0.0 298 | w: 1.0 299 | } 300 | } 301 | components { 302 | id: "on_up_pressed" 303 | component: "/defkit/events/input/on_button_press.script" 304 | position { 305 | x: 0.0 306 | y: 0.0 307 | z: 0.0 308 | } 309 | rotation { 310 | x: 0.0 311 | y: 0.0 312 | z: 0.0 313 | w: 1.0 314 | } 315 | properties { 316 | id: "action_id" 317 | value: "up" 318 | type: PROPERTY_TYPE_HASH 319 | } 320 | } 321 | embedded_components { 322 | id: "collisionobject" 323 | type: "collisionobject" 324 | data: "collision_shape: \"\"\n" 325 | "type: COLLISION_OBJECT_TYPE_TRIGGER\n" 326 | "mass: 0.0\n" 327 | "friction: 0.1\n" 328 | "restitution: 0.5\n" 329 | "group: \"player\"\n" 330 | "mask: \"default\"\n" 331 | "mask: \"point\"\n" 332 | "embedded_collision_shape {\n" 333 | " shapes {\n" 334 | " shape_type: TYPE_BOX\n" 335 | " position {\n" 336 | " x: 0.0\n" 337 | " y: 0.0\n" 338 | " z: 0.0\n" 339 | " }\n" 340 | " rotation {\n" 341 | " x: 0.0\n" 342 | " y: 0.0\n" 343 | " z: 0.0\n" 344 | " w: 1.0\n" 345 | " }\n" 346 | " index: 0\n" 347 | " count: 3\n" 348 | " }\n" 349 | " data: 56.82294\n" 350 | " data: 56.82294\n" 351 | " data: 10.0\n" 352 | "}\n" 353 | "linear_damping: 0.0\n" 354 | "angular_damping: 0.0\n" 355 | "locked_rotation: false\n" 356 | "" 357 | position { 358 | x: 0.0 359 | y: 0.0 360 | z: 0.0 361 | } 362 | rotation { 363 | x: 0.0 364 | y: 0.0 365 | z: 0.0 366 | w: 1.0 367 | } 368 | } 369 | embedded_components { 370 | id: "sprite" 371 | type: "sprite" 372 | data: "tile_set: \"/main/logo.atlas\"\n" 373 | "default_animation: \"logo\"\n" 374 | "material: \"/builtins/materials/sprite.material\"\n" 375 | "blend_mode: BLEND_MODE_ALPHA\n" 376 | "" 377 | position { 378 | x: 0.0 379 | y: 0.0 380 | z: 0.0 381 | } 382 | rotation { 383 | x: 0.0 384 | y: 0.0 385 | z: 0.0 386 | w: 1.0 387 | } 388 | } 389 | -------------------------------------------------------------------------------- /main/point.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "object" 3 | component: "/defkit/object.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | properties { 16 | id: "type" 17 | value: "point" 18 | type: PROPERTY_TYPE_HASH 19 | } 20 | } 21 | components { 22 | id: "on_destroy" 23 | component: "/defkit/events/on_destroy.script" 24 | position { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | components { 37 | id: "set_score" 38 | component: "/defkit/actions/basic2/set_score.script" 39 | position { 40 | x: 0.0 41 | y: 0.0 42 | z: 0.0 43 | } 44 | rotation { 45 | x: 0.0 46 | y: 0.0 47 | z: 0.0 48 | w: 1.0 49 | } 50 | properties { 51 | id: "event" 52 | value: "#on_destroy" 53 | type: PROPERTY_TYPE_URL 54 | } 55 | properties { 56 | id: "score" 57 | value: "10.0" 58 | type: PROPERTY_TYPE_NUMBER 59 | } 60 | properties { 61 | id: "relative" 62 | value: "true" 63 | type: PROPERTY_TYPE_BOOLEAN 64 | } 65 | } 66 | embedded_components { 67 | id: "collisionobject" 68 | type: "collisionobject" 69 | data: "collision_shape: \"\"\n" 70 | "type: COLLISION_OBJECT_TYPE_TRIGGER\n" 71 | "mass: 0.0\n" 72 | "friction: 0.1\n" 73 | "restitution: 0.5\n" 74 | "group: \"point\"\n" 75 | "mask: \"player\"\n" 76 | "embedded_collision_shape {\n" 77 | " shapes {\n" 78 | " shape_type: TYPE_SPHERE\n" 79 | " position {\n" 80 | " x: 0.0\n" 81 | " y: 0.0\n" 82 | " z: 0.0\n" 83 | " }\n" 84 | " rotation {\n" 85 | " x: 0.0\n" 86 | " y: 0.0\n" 87 | " z: 0.0\n" 88 | " w: 1.0\n" 89 | " }\n" 90 | " index: 0\n" 91 | " count: 1\n" 92 | " }\n" 93 | " data: 6.339816\n" 94 | "}\n" 95 | "linear_damping: 0.0\n" 96 | "angular_damping: 0.0\n" 97 | "locked_rotation: false\n" 98 | "" 99 | position { 100 | x: 0.0 101 | y: 0.0 102 | z: 0.0 103 | } 104 | rotation { 105 | x: 0.0 106 | y: 0.0 107 | z: 0.0 108 | w: 1.0 109 | } 110 | } 111 | embedded_components { 112 | id: "sprite" 113 | type: "sprite" 114 | data: "tile_set: \"/builtins/graphics/particle_blob.tilesource\"\n" 115 | "default_animation: \"anim\"\n" 116 | "material: \"/builtins/materials/sprite.material\"\n" 117 | "blend_mode: BLEND_MODE_ALPHA\n" 118 | "" 119 | position { 120 | x: 0.0 121 | y: 0.0 122 | z: 0.0 123 | } 124 | rotation { 125 | x: 0.0 126 | y: 0.0 127 | z: 0.0 128 | w: 1.0 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /main/sounds/strings2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamwestman/defkit/63dc88dcffb6cb676ab13201aaac147d41a6aa2f/main/sounds/strings2.wav -------------------------------------------------------------------------------- /properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamwestman/defkit/63dc88dcffb6cb676ab13201aaac147d41a6aa2f/properties.png --------------------------------------------------------------------------------