init defold game
This commit is contained in:
parent
925d375313
commit
26e88c8f03
20 changed files with 381 additions and 9 deletions
15
defold_game/main/main.atlas
Normal file
15
defold_game/main/main.atlas
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
images {
|
||||
image: "/assets/images/background.png"
|
||||
}
|
||||
images {
|
||||
image: "/assets/images/logo.png"
|
||||
}
|
||||
images {
|
||||
image: "/builtins/graphics/particle_blob.png"
|
||||
}
|
||||
images {
|
||||
image: "/assets/images/player.png"
|
||||
pivot_x: 0.536806
|
||||
pivot_y: 0.447809
|
||||
}
|
||||
extrude_borders: 2
|
||||
79
defold_game/main/main.collection
Normal file
79
defold_game/main/main.collection
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
name: "main"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"main\"\n"
|
||||
" component: \"/main/main.script\"\n"
|
||||
"}\n"
|
||||
"embedded_components {\n"
|
||||
" id: \"logo\"\n"
|
||||
" type: \"sprite\"\n"
|
||||
" data: \"default_animation: \\\"logo\\\"\\n"
|
||||
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
|
||||
"textures {\\n"
|
||||
" sampler: \\\"texture_sampler\\\"\\n"
|
||||
" texture: \\\"/main/main.atlas\\\"\\n"
|
||||
"}\\n"
|
||||
"\"\n"
|
||||
"}\n"
|
||||
"embedded_components {\n"
|
||||
" id: \"background\"\n"
|
||||
" type: \"sprite\"\n"
|
||||
" data: \"default_animation: \\\"background\\\"\\n"
|
||||
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
|
||||
"textures {\\n"
|
||||
" sampler: \\\"texture_sampler\\\"\\n"
|
||||
" texture: \\\"/main/main.atlas\\\"\\n"
|
||||
"}\\n"
|
||||
"\"\n"
|
||||
" position {\n"
|
||||
" z: -0.5\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
""
|
||||
position {
|
||||
x: 640.0
|
||||
y: 360.0
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "camera"
|
||||
data: "embedded_components {\n"
|
||||
" id: \"camera\"\n"
|
||||
" type: \"camera\"\n"
|
||||
" data: \"aspect_ratio: 1.0\\n"
|
||||
"fov: 0.7854\\n"
|
||||
"near_z: -1.0\\n"
|
||||
"far_z: 1.0\\n"
|
||||
"orthographic_projection: 1\\n"
|
||||
"orthographic_mode: ORTHO_MODE_AUTO_COVER\\n"
|
||||
"\"\n"
|
||||
"}\n"
|
||||
""
|
||||
position {
|
||||
x: 640.0
|
||||
y: 360.0
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "player"
|
||||
data: "components {\n"
|
||||
" id: \"body\"\n"
|
||||
" component: \"/main/player.sprite\"\n"
|
||||
" position {\n"
|
||||
" x: 109.0\n"
|
||||
" y: 90.0\n"
|
||||
" }\n"
|
||||
" scale {\n"
|
||||
" x: 2.0\n"
|
||||
" y: 2.0\n"
|
||||
" z: 2.0\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"components {\n"
|
||||
" id: \"player1\"\n"
|
||||
" component: \"/main/player.script\"\n"
|
||||
"}\n"
|
||||
""
|
||||
}
|
||||
10
defold_game/main/main.script
Normal file
10
defold_game/main/main.script
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- function init(self)
|
||||
-- msg.post(".", "acquire_input_focus")
|
||||
-- end
|
||||
--
|
||||
-- function on_input(self, action_id, action)
|
||||
-- if action_id == hash("touch") and action.pressed then
|
||||
-- print("Touch!")
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
30
defold_game/main/player.script
Normal file
30
defold_game/main/player.script
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
function init(self)
|
||||
msg.post(".", "acquire_input_focus") -- <1>
|
||||
self.vel = vmath.vector3() -- <2>
|
||||
end
|
||||
|
||||
function update(self, dt)
|
||||
local pos = go.get_position() -- <3>
|
||||
pos = pos + self.vel * dt -- <4>
|
||||
go.set_position(pos) -- <5>
|
||||
|
||||
self.vel.x = 0 -- <6>
|
||||
self.vel.y = 0
|
||||
|
||||
-- sprite.play_flipbook("#body", "s")
|
||||
rot = go.get_rotation()
|
||||
print(rot)
|
||||
|
||||
end
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
if action_id == hash("up") then
|
||||
self.vel.y = 150 -- <7>
|
||||
elseif action_id == hash("down") then
|
||||
self.vel.y = -150
|
||||
elseif action_id == hash("left") then
|
||||
self.vel.x = -150 -- <8>
|
||||
elseif action_id == hash("right") then
|
||||
self.vel.x = 150
|
||||
end
|
||||
end
|
||||
6
defold_game/main/player.sprite
Normal file
6
defold_game/main/player.sprite
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
default_animation: "n"
|
||||
material: "/builtins/materials/sprite.material"
|
||||
textures {
|
||||
sampler: "texture_sampler"
|
||||
texture: "/main/player.tilesource"
|
||||
}
|
||||
52
defold_game/main/player.tilesource
Normal file
52
defold_game/main/player.tilesource
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
image: "/assets/images/player.png"
|
||||
tile_width: 25
|
||||
tile_height: 25
|
||||
collision_groups: "player"
|
||||
animations {
|
||||
id: "e"
|
||||
start_tile: 4
|
||||
end_tile: 4
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "n"
|
||||
start_tile: 1
|
||||
end_tile: 1
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "ne"
|
||||
start_tile: 3
|
||||
end_tile: 3
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "nw"
|
||||
start_tile: 8
|
||||
end_tile: 8
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "s"
|
||||
start_tile: 2
|
||||
end_tile: 2
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "se"
|
||||
start_tile: 5
|
||||
end_tile: 5
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "sw"
|
||||
start_tile: 6
|
||||
end_tile: 6
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
animations {
|
||||
id: "w"
|
||||
start_tile: 7
|
||||
end_tile: 7
|
||||
playback: PLAYBACK_NONE
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue