*.code-workspace
*.sublime-project
*.sublime-workspace
-src/config.onyx
\ No newline at end of file
+src/config.onyx
+*.wasm
\ No newline at end of file
"problemMatcher": "$onyx",
"command": "./run.sh",
"args": ["build"],
+ "presentation": {
+ "echo": true,
+ "reveal": "silent",
+ "focus": false,
+ "panel": "shared",
+ "showReuseMessage": false,
+ "clear": true,
+ },
"group": {
"kind": "build",
"isDefault": true
consume_timeout: f32;
init :: (use this: ^PatronComponent) {
- printf("{*}\n", ^item_store.items);
- items := item_store.items.entries;
- r := random.between(0, (items.count - 1));
- order_item = items[r].key;
- printf("{} {} {}\n", order_item, r, items.count);
+ order_item = random.choice(item_store.items.entries).key;
}
added :: (use this: ^PatronComponent, entity: ^Entity) {
}
}
+ find_available_seat :: (use this: ^PatronComponent) -> bool {
+ seats := scene->query_by_component(.{ 0, 0, 10000, 10000 }, FurnitureComponent);
+ defer memory.free_slice(^seats);
+ if seats.count == 0 do return false;
+
+ while seat == Entity_Nothing {
+ it := random.choice(seats);
+ furniture := it->get(FurnitureComponent);
+ if furniture.furniture_type != .Seat do continue;
+ if furniture->try_take() {
+ seat = it.id;
+ break;
+ }
+ }
+
+ return true;
+ }
+
update :: (use this: ^PatronComponent, entity: ^Entity, dt: f32) {
if state == .Walking_To_Seat {
if seat == Entity_Nothing {
- seats := scene->query_by_component(.{ 0, 0, 10000, 10000 }, FurnitureComponent);
- defer memory.free_slice(^seats);
-
- for seats {
- furniture := it->get(FurnitureComponent);
- if furniture.furniture_type != .Seat do continue;
- if furniture->try_take() {
- seat = it.id;
- break;
- }
- }
-
- if seat == Entity_Nothing {
+ found_seat := this->find_available_seat();
+ if !found_seat {
state = .Leaving;
return;
}
}
draw_textbox(.{x, y + 72.0f, w / 2.0f, 36.0f}, ^test);
-
- #persist dumb := false;
-
- draw_checkbox(.{x, y + 150, w, 36.0f}, ^dumb, "Testing checkboxes");
}
#local render_entity_list :: (x, y, w, h: f32) {
+ scrolling_region_start(.{x, y, w, h});
+
buf: [256] u8;
for scene.entities {
msg := conv.format(buf, "{} ({})", it.schematic, cast(u32) it.id);
}
y += 32;
}
+
+ scrolling_region_stop();
}
#local render_entity_fields :: (entity: ^Entity, x, y, w, h: f32) {
item_store->load_items_from_file("scenes/default.items");
}
+game_deinit :: () {
+ Audio_Manager.deinit();
+}
+
#local quick_save_file := "scenes/quick_save_new.scene";
game_update :: (dt: f32) {
#if DEBUG { debug_font = font_lookup(.{"./assets/fonts/calibri.ttf", 16}); }
}
+deinit :: () {
+ game_deinit();
+}
+
update :: (dt: f32) {
input_update();
}
main :: (args) => {
- // random.set_seed(os.time());
+ random.set_seed(os.time());
debug_set_level(.Debug);
if !glfwInit() {
defer pos += n;
return data[pos .. pos+n];
}
-}
-
-
-#if false {
-main :: (args) => {
- dev := alcOpenDevice(null);
- defer alcCloseDevice(dev);
-
- con := alcCreateContext(dev, null);
- alcMakeContextCurrent(con);
- defer {
- alcMakeContextCurrent(~~ cast(u64) 0);
- alcDestroyContext(con);
- }
-
- alGetError();
- buf: u32;
- alGenBuffers(1, ^buf);
- defer alDeleteBuffers(1, ^buf);
- if error := alGetError(); error != AL_NO_ERROR {
- printf("AL ERROR: {}\n", error);
- return;
- }
-
- sample_rate := 44100;
-
-/*
- wav_data := memory.make_slice(i16, sample_rate * 5);
- for i: wav_data.count {
- sample := math.sin((math.PI * 2.0f * ~~i * 263.2f) / ~~sample_rate) * 32768;
- sample *= 1 - cast(f32) i / ~~wav_data.count;
- wav_data[i] = cast(i16) cast(i32) (sample);
- }
- */
-
- wav_file_contents := os.get_contents("/home/brendan/test.wav");
- wav_data := extract_wav_file_data(wav_file_contents);
-
- alBufferData(buf, AL_FORMAT_STEREO16, wav_data.data, wav_data.count, sample_rate);
-
- alListener3f(AL_POSITION, 0, 0, 0);
- alListener3f(AL_VELOCITY, 0, 0, 0);
- alListenerfv(AL_ORIENTATION, ~~ f32.[0, 0, 1, 0, 1, 0]);
-
- source: u32;
- alGenSources(1, ^source);
- defer alDeleteSources(1, ^source);
- alSourcef(source, AL_PITCH, 1);
- alSourcef(source, AL_GAIN, 0.7);
- alSource3f(source, AL_POSITION, 0, 0, 0);
- alSource3f(source, AL_VELOCITY, 0, 0, 0);
- alSourcei(source, AL_LOOPING, AL_FALSE);
-
- alSourcei(source, AL_BUFFER, buf);
- alSourcePlay(source);
-
- state: i32;
- while true {
- os.sleep(1000);
- alGetSourcei(source, AL_SOURCE_STATE, ^state);
- if state != AL_PLAYING do break;
- }
-}
}
\ No newline at end of file