Initial push

This commit is contained in:
Ronja 2021-05-23 15:32:50 +02:00
commit c87b31968b
27 changed files with 656 additions and 0 deletions

10
.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
*/.DS_Store
.DS_Store
.DS_Store?
*/thumbs.db
thumbs.db
.thumbs.db?
.luxe/
_luxe.data/
_luxe.deploy/
log.txt

17
.vscode/tasks.json vendored Normal file
View file

@ -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"
}
]
}

View file

@ -0,0 +1,4 @@
image = {
source = "assets/prototype/Edges.png"
generate_mipmaps_at_load = false
}

BIN
assets/prototype/Edges.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,4 @@
image = {
source = "assets/prototype/HexBorders.png"
generate_mipmaps_at_load = false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,4 @@
image = {
source = "assets/prototype/HexEdge.png"
generate_mipmaps_at_load = false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,4 @@
image = {
source = "assets/prototype/Hexagon.png"
generate_mipmaps_at_load = false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -0,0 +1,4 @@
image = {
source = "assets/prototype/SharkCard.png"
generate_mipmaps_at_load = false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 KiB

36
field.wren Normal file
View file

@ -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)
}
}
}

56
game.wren Normal file
View file

@ -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

View file

@ -0,0 +1,4 @@
material = {
basis = "luxe: material_basis/sprite"
inputs = { sprite.image = "assets/prototype/HexBorders" }
}

View file

@ -0,0 +1,4 @@
material = {
basis = "luxe: material_basis/sprite"
inputs = { sprite.image = "assets/prototype/HexEdge" }
}

View file

@ -0,0 +1,4 @@
material = {
basis = "luxe: material_basis/sprite"
inputs = { sprite.image = "assets/prototype/Edges" }
}

View file

@ -0,0 +1,7 @@
material = {
basis = "shaders/sprite_masked"
inputs = {
sprite.image = "assets/prototype/SharkCard"
sprite.mask = "assets/prototype/Hexagon"
}
}

74
outline/app.wren Normal file
View 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
View 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
View 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

View 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
View file

@ -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

3
project.modules.lx Normal file
View file

@ -0,0 +1,3 @@
modules = {
luxe = "2021.0.3"
} //modules

195
prototype/card.prototype.lx Normal file
View file

@ -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

View file

@ -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;
}

View file

@ -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]
}
}
}