first
This commit is contained in:
commit
14eaf3c5af
8 changed files with 262 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
*/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
*/thumbs.db
|
||||
thumbs.db
|
||||
.thumbs.db?
|
||||
.luxe/
|
||||
_luxe.data/
|
||||
_luxe.deploy/
|
||||
log.txt
|
||||
70
game.wren
Normal file
70
game.wren
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import "luxe: game" for Ready
|
||||
import "luxe: assets" for Assets
|
||||
import "luxe: input" for Input, Key, MouseButton
|
||||
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera, Text
|
||||
import "luxe: math" for Math
|
||||
import "luxe: draw" for Draw
|
||||
import "luxe: io" for IO
|
||||
|
||||
import "outline/app" for App
|
||||
|
||||
class Game is Ready {
|
||||
|
||||
construct ready() {
|
||||
|
||||
super("ready!")
|
||||
|
||||
app = App.new()
|
||||
|
||||
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
|
||||
|
||||
_spritecount = 0
|
||||
var instructiontext = Entity.create(app.ui)
|
||||
var font = Assets.material("luxe: material/font")
|
||||
Transform.create(instructiontext)
|
||||
Transform.set_pos(instructiontext, 10, 10)
|
||||
Text.create(instructiontext, font, 32, "luxe: fonts/lato", [1,1,1,1])
|
||||
Text.set_text(instructiontext, "right click to rapidly spawn sprites, left click to spawn one at a time")
|
||||
|
||||
} //ready
|
||||
|
||||
tick(delta) {
|
||||
|
||||
if(Input.mouse_state_down(MouseButton.right)) {
|
||||
_logo = Entity.create(app.world, "sprite")
|
||||
Transform.create(_logo)
|
||||
var pos = Camera.screen_point_to_world(app.camera, Input.mouse_x(), Input.mouse_y())
|
||||
Transform.set_pos(_logo, pos.x, pos.y, 0)
|
||||
Sprite.create(_logo, Assets.material("luxe: material/logo"), 128, 128)
|
||||
_spritecount = _spritecount + 1
|
||||
System.print(_spritecount)
|
||||
}
|
||||
if(Input.mouse_state_pressed(MouseButton.left)) {
|
||||
_logo = Entity.create(app.world, "sprite")
|
||||
Transform.create(_logo)
|
||||
var pos = Camera.screen_point_to_world(app.camera, Input.mouse_x(), Input.mouse_y())
|
||||
Transform.set_pos(_logo, pos.x, pos.y, 0)
|
||||
Sprite.create(_logo, Assets.material("luxe: material/logo"), 128, 128)
|
||||
_spritecount = _spritecount + 1
|
||||
System.print(_spritecount)
|
||||
}
|
||||
|
||||
if(Input.key_state_released(Key.escape)) {
|
||||
IO.shutdown()
|
||||
}
|
||||
|
||||
app.color.r = app.color.g = app.color.b = (IO.timestamp()/20 % 1)
|
||||
|
||||
} //tick
|
||||
|
||||
destroy() {
|
||||
|
||||
System.print("unready!")
|
||||
app.destroy()
|
||||
|
||||
} //destroy
|
||||
|
||||
app { _app }
|
||||
app=(v) { _app=v }
|
||||
|
||||
} //Game
|
||||
74
outline/app.wren
Normal file
74
outline/app.wren
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import "luxe: world" for World, Camera, Entity, Transform
|
||||
import "luxe: render" for Render
|
||||
import "luxe: game" for Frame
|
||||
|
||||
class App {
|
||||
|
||||
world { _world }
|
||||
ui { _ui_world }
|
||||
|
||||
camera { _camera }
|
||||
ui_camera { _ui_camera }
|
||||
|
||||
color { _color }
|
||||
color=(v) { _color = v }
|
||||
|
||||
width { Render.window_w() }
|
||||
height { Render.window_h() }
|
||||
scale { Render.drawable_ratio() }
|
||||
|
||||
construct new() {
|
||||
|
||||
_color = [1,1,1,1]
|
||||
|
||||
//create worlds
|
||||
|
||||
_world = World.create("game")
|
||||
_ui_world = World.create("ui")
|
||||
|
||||
//create cameras
|
||||
|
||||
_camera = Entity.create(_world, "app.camera")
|
||||
Transform.create(_camera)
|
||||
Camera.create(_camera)
|
||||
Camera.set_default(_world, _camera)
|
||||
|
||||
_ui_camera = Entity.create(_ui_world, "app.ui_camera")
|
||||
Transform.create(_ui_camera)
|
||||
Camera.create(_ui_camera)
|
||||
Camera.set_default(_ui_world, _ui_camera)
|
||||
|
||||
//update our worlds
|
||||
|
||||
Frame.on(Frame.sim) {|delta|
|
||||
World.tick(_world, delta)
|
||||
World.tick(_ui_world, delta)
|
||||
}
|
||||
|
||||
//render our worlds
|
||||
|
||||
Frame.on(Frame.visual) {|delta|
|
||||
World.render(_world, _camera, "game", {"clear_color":_color})
|
||||
World.render(_ui_world, _ui_camera, "ui")
|
||||
}
|
||||
|
||||
} //new
|
||||
|
||||
destroy() {
|
||||
|
||||
//destroy cameras
|
||||
|
||||
Camera.destroy(_camera)
|
||||
Camera.destroy(_ui_camera)
|
||||
|
||||
Entity.destroy(_camera)
|
||||
Entity.destroy(_ui_camera)
|
||||
|
||||
//destroy worlds
|
||||
|
||||
World.destroy(_ui_world)
|
||||
World.destroy(_world)
|
||||
|
||||
} //destroy
|
||||
|
||||
} //
|
||||
23
outline/inputs.input.lx
Normal file
23
outline/inputs.input.lx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
input = {
|
||||
nodes = [
|
||||
{ name = "ui" where = "front" channels = ["c01"] }
|
||||
{ name = "game" where = "after: ui" channels = ["c02"] }
|
||||
]
|
||||
|
||||
map = {
|
||||
left = { keys = ["key_a", "left"] }
|
||||
right = { keys = ["key_d", "right"] }
|
||||
up = { keys = ["key_w", "up"] }
|
||||
down = { keys = ["key_s", "down"] }
|
||||
jump = {
|
||||
keys = ["key_x", "up", "key_w", "space"]
|
||||
mouse = ["left"]
|
||||
gamepad = [0]
|
||||
}
|
||||
|
||||
next = {
|
||||
keys = ["key_x", "up", "key_w", "space", "enter", "escape"]
|
||||
mouse = ["left", "right"]
|
||||
}
|
||||
}
|
||||
}
|
||||
51
outline/renderer.wren
Normal file
51
outline/renderer.wren
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import "luxe: render" for Render, RenderLayerDesc, PassLayerDesc, LoadAction
|
||||
import "luxe: render" for SortType, ImageDesc, ImageType, PixelFormat
|
||||
|
||||
class Renderer {
|
||||
|
||||
construct new() {
|
||||
|
||||
System.print("game / render / init / ok")
|
||||
|
||||
} //new
|
||||
|
||||
ready() {
|
||||
|
||||
}
|
||||
|
||||
tick(delta) {
|
||||
|
||||
}
|
||||
|
||||
render_path(ctx) {
|
||||
|
||||
if(ctx.path == "game") {
|
||||
game_render_path(ctx)
|
||||
} else if(ctx.path == "ui") {
|
||||
ui_render_path(ctx)
|
||||
}
|
||||
|
||||
} //render_path
|
||||
|
||||
game_render_path(ctx) {
|
||||
|
||||
var layer = RenderLayerDesc.new()
|
||||
layer.dest.color[0].clear_color = ctx.get("clear_color", [1,1,1,1])
|
||||
layer.dest.color[0].load_action = LoadAction.clear
|
||||
layer.dest.depth.load_action = LoadAction.clear
|
||||
|
||||
ctx.layer_render("default", layer)
|
||||
|
||||
} //game_render_path
|
||||
|
||||
ui_render_path(ctx) {
|
||||
|
||||
var layer = RenderLayerDesc.new()
|
||||
layer.dest.color[0].load_action = LoadAction.dont_care
|
||||
layer.dest.depth.load_action = LoadAction.clear
|
||||
|
||||
ctx.layer_render("default", layer)
|
||||
|
||||
} //ui_render_path
|
||||
|
||||
} //Renderer
|
||||
17
outline/settings.settings.lx
Normal file
17
outline/settings.settings.lx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
engine = {
|
||||
input.entry = "outline/inputs"
|
||||
runtime = {
|
||||
window = {
|
||||
width = 960
|
||||
height = 640
|
||||
resizable = false
|
||||
fullscreen = false
|
||||
}
|
||||
}
|
||||
|
||||
render = {
|
||||
antialiasing = 2
|
||||
stencil = 8
|
||||
depth = 24
|
||||
}
|
||||
}
|
||||
14
project.luxe
Normal file
14
project.luxe
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import "luxe: project" for Entry
|
||||
|
||||
class Project is Entry {
|
||||
|
||||
construct entry(target) {
|
||||
|
||||
name = "sprite_spawn_bug"
|
||||
version = "0.0.0"
|
||||
renderer = "outline/renderer"
|
||||
settings = "outline/settings"
|
||||
|
||||
} //new
|
||||
|
||||
} //Project
|
||||
3
project.modules.lx
Normal file
3
project.modules.lx
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
modules = {
|
||||
luxe = "2020.3.0"
|
||||
} //modules
|
||||
Loading…
Reference in a new issue