commit c87b31968b406f3a3e347d3e7f93002c194feb74 Author: Ronja Date: Sun May 23 15:32:50 2021 +0200 Initial push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9dc9db --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*/.DS_Store +.DS_Store +.DS_Store? +*/thumbs.db +thumbs.db +.thumbs.db? +.luxe/ +_luxe.data/ +_luxe.deploy/ +log.txt \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..4f2c46b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "tasks": [ + { + "type": "luxe", + "script": "run", + "problemMatcher": [ + "$luxe-absolute", + "$luxe-relative" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "luxe: run - Build & Run the project" + } + ] +} \ No newline at end of file diff --git a/assets/prototype/Edges.image.lx b/assets/prototype/Edges.image.lx new file mode 100644 index 0000000..ad33eca --- /dev/null +++ b/assets/prototype/Edges.image.lx @@ -0,0 +1,4 @@ +image = { + source = "assets/prototype/Edges.png" + generate_mipmaps_at_load = false +} \ No newline at end of file diff --git a/assets/prototype/Edges.png b/assets/prototype/Edges.png new file mode 100644 index 0000000..42590ed Binary files /dev/null and b/assets/prototype/Edges.png differ diff --git a/assets/prototype/HexBorders.image.lx b/assets/prototype/HexBorders.image.lx new file mode 100644 index 0000000..2aeeff4 --- /dev/null +++ b/assets/prototype/HexBorders.image.lx @@ -0,0 +1,4 @@ +image = { + source = "assets/prototype/HexBorders.png" + generate_mipmaps_at_load = false +} \ No newline at end of file diff --git a/assets/prototype/HexBorders.png b/assets/prototype/HexBorders.png new file mode 100644 index 0000000..37a5382 Binary files /dev/null and b/assets/prototype/HexBorders.png differ diff --git a/assets/prototype/HexEdge.image.lx b/assets/prototype/HexEdge.image.lx new file mode 100644 index 0000000..bcc288b --- /dev/null +++ b/assets/prototype/HexEdge.image.lx @@ -0,0 +1,4 @@ +image = { + source = "assets/prototype/HexEdge.png" + generate_mipmaps_at_load = false +} \ No newline at end of file diff --git a/assets/prototype/HexEdge.png b/assets/prototype/HexEdge.png new file mode 100644 index 0000000..749eadc Binary files /dev/null and b/assets/prototype/HexEdge.png differ diff --git a/assets/prototype/Hexagon.image.lx b/assets/prototype/Hexagon.image.lx new file mode 100644 index 0000000..fc21db4 --- /dev/null +++ b/assets/prototype/Hexagon.image.lx @@ -0,0 +1,4 @@ +image = { + source = "assets/prototype/Hexagon.png" + generate_mipmaps_at_load = false +} \ No newline at end of file diff --git a/assets/prototype/Hexagon.png b/assets/prototype/Hexagon.png new file mode 100644 index 0000000..2324ebc Binary files /dev/null and b/assets/prototype/Hexagon.png differ diff --git a/assets/prototype/SharkCard.image.lx b/assets/prototype/SharkCard.image.lx new file mode 100644 index 0000000..0ffcc4f --- /dev/null +++ b/assets/prototype/SharkCard.image.lx @@ -0,0 +1,4 @@ +image = { + source = "assets/prototype/SharkCard.png" + generate_mipmaps_at_load = false +} \ No newline at end of file diff --git a/assets/prototype/SharkCard.png b/assets/prototype/SharkCard.png new file mode 100644 index 0000000..cff7d0a Binary files /dev/null and b/assets/prototype/SharkCard.png differ diff --git a/field.wren b/field.wren new file mode 100644 index 0000000..656bcb9 --- /dev/null +++ b/field.wren @@ -0,0 +1,36 @@ +import "luxe: world" for Prototype, Entity + + +var Slots = [ + [-1, +3, -2], [ 0, +2, -2], [ 1, +1, -2], [ 2, +0, -2], [ 3, -1, -2], + [-2, +3, -1], [-1, +2, -1], [ 0, +1, -1], [ 1, +0, -1], [ 2, -1, -1], [ 3, -2, -1], + [-3, +3, +0], [-2, +2, +0], [-1, +1, +0], [ 0, +0, +0], [ 1, -1, +0], [ 2, -2, +0], [ 3, -3, 0], + [-3, +2, +1], [-2, +1, +1], [-1, +0, +1], [ 0, -1, +1], [ 1, -2, +1], [ 2, -3, +1], + [-3, +1, +2], [-2, +0, +2], [-1, -1, +2], [ 0, -2, +2], [ 1, -3, +2] +] + +var x_angle = 1 * Num.tau / 12 +var y_angle = 5 * Num.tau / 12 +var z_angle = 9 * Num.tau / 12 +var X_Dir = [x_angle.cos, x_angle.sin, 0] +var Y_Dir = [y_angle.cos, y_angle.sin, 0] +var Z_Dir = [z_angle.cos, z_angle.sin, 0] + +class Field{ + + construct new(world){ + _world = world + _root = Entity.create(world) + _slots = [] + } + + add_slot(slot: List /*of Num*/){ + Prototype.create(_world, "prototype/card", "card(%(slot.x), %(slot.y), %(slot.z))", [0, 0, 0], [0,0,0], [2,2,2]) + } + + add_slots(slots: List /*of List of Num*/){ + for(slot in slots){ + add_slot(slot) + } + } +} \ No newline at end of file diff --git a/game.wren b/game.wren new file mode 100644 index 0000000..8fe6fb3 --- /dev/null +++ b/game.wren @@ -0,0 +1,56 @@ +import "luxe: game" for Ready +import "luxe: assets" for Assets +import "luxe: input" for Input, Key +import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera, Text, Prototype, Anim +import "luxe: math" for Math +import "luxe: draw" for Draw +import "luxe: io" for IO +import "luxe: lx" for LX +import "field" for Field, Slots + +import "outline/app" for App + +class Game is Ready { + + construct ready() { + + super("ready!") + + app = App.new() + app.color = [0,0,0,1] + + System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x") + + _logo = Entity.create(app.world, "sprite") + Transform.create(_logo) + Transform.set_pos(_logo, app.width/2, app.height/2, 0) + Text.create(_logo, Assets.material("luxe: material/font"), 42, "luxe: fonts/lato", [1,1,1,1]) + Text.set_text(_logo, "Lorem Ipsum dolor sit amet") + + _playField = Field.new(app.world) + } //ready + + tick(delta) { + + var pos = Camera.screen_point_to_world(app.camera, Input.mouse_x(), Input.mouse_y()) + Transform.set_pos(_logo, pos.x, pos.y, 0) + + 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 diff --git a/material/border.material.lx b/material/border.material.lx new file mode 100644 index 0000000..9511ce5 --- /dev/null +++ b/material/border.material.lx @@ -0,0 +1,4 @@ +material = { + basis = "luxe: material_basis/sprite" + inputs = { sprite.image = "assets/prototype/HexBorders" } +} diff --git a/material/edge.material.lx b/material/edge.material.lx new file mode 100644 index 0000000..09f769e --- /dev/null +++ b/material/edge.material.lx @@ -0,0 +1,4 @@ +material = { + basis = "luxe: material_basis/sprite" + inputs = { sprite.image = "assets/prototype/HexEdge" } +} diff --git a/material/edges.material.lx b/material/edges.material.lx new file mode 100644 index 0000000..20d2b0a --- /dev/null +++ b/material/edges.material.lx @@ -0,0 +1,4 @@ +material = { + basis = "luxe: material_basis/sprite" + inputs = { sprite.image = "assets/prototype/Edges" } +} diff --git a/material/hexagon.material.lx b/material/hexagon.material.lx new file mode 100644 index 0000000..eba4fb4 --- /dev/null +++ b/material/hexagon.material.lx @@ -0,0 +1,7 @@ +material = { + basis = "shaders/sprite_masked" + inputs = { + sprite.image = "assets/prototype/SharkCard" + sprite.mask = "assets/prototype/Hexagon" + } +} diff --git a/outline/app.wren b/outline/app.wren new file mode 100644 index 0000000..a0f1768 --- /dev/null +++ b/outline/app.wren @@ -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 + +} // diff --git a/outline/inputs.input.lx b/outline/inputs.input.lx new file mode 100644 index 0000000..dc45459 --- /dev/null +++ b/outline/inputs.input.lx @@ -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"] + } + } +} diff --git a/outline/renderer.wren b/outline/renderer.wren new file mode 100644 index 0000000..8c00ab4 --- /dev/null +++ b/outline/renderer.wren @@ -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 diff --git a/outline/settings.settings.lx b/outline/settings.settings.lx new file mode 100644 index 0000000..fe39e7e --- /dev/null +++ b/outline/settings.settings.lx @@ -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 + } +} \ No newline at end of file diff --git a/project.luxe b/project.luxe new file mode 100644 index 0000000..d19c5b7 --- /dev/null +++ b/project.luxe @@ -0,0 +1,14 @@ +import "luxe: project" for Entry + +class Project is Entry { + + construct entry(target) { + + name = "HexCards" + version = "0.0.1" + renderer = "outline/renderer" + settings = "outline/settings" + + } //new + +} //Project \ No newline at end of file diff --git a/project.modules.lx b/project.modules.lx new file mode 100644 index 0000000..0858dd2 --- /dev/null +++ b/project.modules.lx @@ -0,0 +1,3 @@ +modules = { + luxe = "2021.0.3" +} //modules diff --git a/prototype/card.prototype.lx b/prototype/card.prototype.lx new file mode 100644 index 0000000..0d1689a --- /dev/null +++ b/prototype/card.prototype.lx @@ -0,0 +1,195 @@ +prototype = { + elements = { + edge_ne = { + modifiers = { + sprite = { + material = "material/edge" + color = [1 1 1 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "f873fe05-6771-496f-b56a-713d7f5fc622" + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + rotation = [0 0 60.00000166965211] //rotation + } //transform + } //modifiers + uuid = "6f4e045a-52e2-41e9-a80b-f05eb95b6b41" + } //edge_ne + edge_se = { + modifiers = { + sprite = { + material = "material/edge" + color = [0.7 0 0.8 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "f873fe05-6771-496f-b56a-713d7f5fc622" + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + rotation = [0 0 -60.00000849984128] //rotation + } //transform + } //modifiers + uuid = "dda3e025-14d8-452a-af4c-c27fdc4c1776" + } //edge_se + edge_e = { + modifiers = { + sprite = { + material = "material/edge" + color = [1 0 0 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "f873fe05-6771-496f-b56a-713d7f5fc622" + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + } //transform + } //modifiers + uuid = "1ba8801c-f238-4602-b7a4-3ee4f8bbd468" + } //edge_e + bg = { + modifiers = { + sprite = { + material = "material/hexagon" + height = 64 + uv = [0 0 1 1] //uv + color = [1 1 1 1] //color + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + type = "luxe: modifier/transform" + } //transform + } //modifiers + uuid = "86fc6726-97dd-4b77-8ded-a5da1aabe698" + } //bg + border = { + modifiers = { + sprite = { + material = "material/border" + color = [0.341176 0.203922 0.0588235 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "86fc6726-97dd-4b77-8ded-a5da1aabe698" + scale = [1.049999952316284 1.049999952316284 1] //scale + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + } //transform + } //modifiers + uuid = "ee4f142f-f5e1-49df-94c9-371f582d63f5" + } //border + edge_nw = { + modifiers = { + sprite = { + material = "material/edge" + color = [0 0 1 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "f873fe05-6771-496f-b56a-713d7f5fc622" + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + rotation = [0 0 120.0000033393042] //rotation + } //transform + } //modifiers + uuid = "8d6b1d9f-0a29-4c02-961a-1274fb140101" + } //edge_nw + title = { + modifiers = { + text = { + material = "luxe: material/font" + align_vertical = "center" + size = 6 + type = "luxe: modifier/text" + text = "Shork" + align = "center" + } //text + transform = { + pos = [0 -12.85531902313232 1] //pos + type = "luxe: modifier/transform" + } //transform + } //modifiers + uuid = "61eceb5b-ff43-4ae1-bb38-382209fcba98" + } //title + edge_w = { + modifiers = { + sprite = { + material = "material/edge" + color = [0 0.8 0 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "f873fe05-6771-496f-b56a-713d7f5fc622" + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + rotation = [0 0 -179.999991348578] //rotation + } //transform + } //modifiers + uuid = "c1531b18-f282-4311-801f-86015db22546" + } //edge_w + edge_sw = { + modifiers = { + sprite = { + material = "material/edge" + color = [0.4 0.3 0.1 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + link = "f873fe05-6771-496f-b56a-713d7f5fc622" + pos = [0 0 1] //pos + type = "luxe: modifier/transform" + rotation = [0 0 -119.9999896789259] //rotation + } //transform + } //modifiers + uuid = "3bacb0d2-03ac-4c3d-91e7-ccab18e1cc52" + } //edge_sw + text_bg = { + modifiers = { + sprite = { + material = "luxe: material/solid" + color = [0 0 0 0.3] //color + height = 10 + type = "luxe: modifier/sprite" + width = 40 + } //sprite + transform = { + pos = [0 -13.08282947540283 0.1000000014901161] //pos + type = "luxe: modifier/transform" + } //transform + } //modifiers + uuid = "b32c57b3-856c-42bb-9fd4-e9d8eb201ea6" + } //text_bg + edges = { + modifiers = { + sprite = { + material = "material/edges" + color = [1 1 1 1] //color + height = 64 + type = "luxe: modifier/sprite" + width = 64 + } //sprite + transform = { + scale = [0.9900000095367432 0.9900000095367432 0.9900000095367432] //scale + link = "86fc6726-97dd-4b77-8ded-a5da1aabe698" + type = "luxe: modifier/transform" + } //transform + } //modifiers + uuid = "f873fe05-6771-496f-b56a-713d7f5fc622" + } //edges + } //elements +} //prototype diff --git a/shaders/sprite_masked.emsl b/shaders/sprite_masked.emsl new file mode 100644 index 0000000..0e8df5b --- /dev/null +++ b/shaders/sprite_masked.emsl @@ -0,0 +1,66 @@ +input View { + mat4 mvp, + mat4 proj, + mat4 proj_inverse, + mat4 view, + mat4 world, //geometry.world atm + float2 fov, //fov.x, fov.y + float2 resolution, + float4 target_region, + float4 target_region_size +} + +input MaskedSprite { + float4 uv, + float4 color, + float2 skew, + bool2 uv_flip, + #0 image2D image, + #1 image2D mask + // bool flipy +} + +stage vertex vert( + input { View view, MaskedSprite sprite }, + vertex in { #0 float4 pos, #1 float4 color, #2 float2 uv }, + fragment out { float4 color, float2 uv}) +{ + out.color = in.color; + out.uv = in.uv; + + mat4 skew = mat4( + float4(1,input.sprite.skew.x,0,0), + float4(input.sprite.skew.y,1,0,0), + float4(0,0,1,0), + float4(0,0,0,1) + ); + + stage.pos = input.view.mvp * (skew * float4(in.pos.xyz, 1.0)); +} + +stage fragment frag( + input { MaskedSprite sprite }, + fragment in { float4 color, float2 uv }) +{ + float4 uv = input.sprite.uv; + + if(input.sprite.uv_flip.x) { + uv.x = input.sprite.uv.z; //left + uv.z = input.sprite.uv.x; //right + } + + if(input.sprite.uv_flip.y) { + uv.y = input.sprite.uv.w; //top + uv.w = input.sprite.uv.y; //bottom + } + + float4 color = texture(input.sprite.image, uv.xy + (in.uv.xy * (uv.zw - uv.xy))); + color.a *= texture(input.sprite.mask, in.uv.xy).a; + + if(color.a <= 0.0) { + discard; + return; + } + + stage.color[0] = color * in.color * input.sprite.color; +} \ No newline at end of file diff --git a/shaders/sprite_masked.material_basis.lx b/shaders/sprite_masked.material_basis.lx new file mode 100644 index 0000000..72475d9 --- /dev/null +++ b/shaders/sprite_masked.material_basis.lx @@ -0,0 +1,55 @@ +material_basis = { + vertex_format = "luxe.textured" + shaders = { + vertex = { library="shaders/sprite_masked" function="vert" } + fragment = { library="shaders/sprite_masked" function="frag" } + } + depth_test = true + depth_write = true + depth_compare = "less_equal" + stencil_test = false + write_mask = { red=true green=true blue=true alpha=true } + blending = true + alpha_blend = "add" + rgb_blend = "add" + src_alpha = "source_alpha" + src_rgb = "source_alpha" + dest_alpha = "one_minus_source_alpha" + dest_rgb = "one_minus_source_alpha" + blend_color = [0 0 0 0] + cull = "none" + winding = "counter_clockwise" + layers = ["default"] + inputs = { + sprite.image = { + type = "image" + value = { + type = "image2D" + sampler_state = "linear_repeat" + } + } + sprite.mask = { + type = "image" + value = { + type = "image2D" + sampler_state = "linear_repeat" + } + } + sprite.uv = { + type = "float4" + value = [0 0 1 1] + } + sprite.uv_flip = { + type = "bool2" + value = [false false] + } + sprite.color = { + type = "float4" + value = [1 1 1 1] + } + sprite.skew = { + type = "float2" + value = [0 0] + } + } +} \ No newline at end of file