Restarted Zig project with the new build architecture
Some checks failed
Build / build (macos-latest) (push) Has been cancelled
Build / build (windows-latest) (push) Has been cancelled
Build / ubuntu-build (push) Has been cancelled
Build / lint (push) Has been cancelled

- Renamed old src directory as backup-src
This commit is contained in:
Tony Bark 2025-02-18 08:02:51 -05:00
parent 5fa931b44e
commit e9d7d736eb
17 changed files with 316 additions and 267 deletions

0
backup-src/api/auth.zig Normal file
View file

42
backup-src/common/map.zig Normal file
View file

@ -0,0 +1,42 @@
pub const LotCategory = enum(u32) {
none = 0,
money = 1,
offbeat = 2,
romance = 3,
services = 4,
shopping = 5,
skills = 6,
welcome = 7,
games = 8,
entertainment = 9,
residence = 10,
community = 11, //cannot be set by users
recent = 255, //for filter searches
};
pub const Top100Category = enum(32) {
lot_money = 1,
lot_offbeat = 2,
lot_romance = 3,
lot_services = 4,
lot_shopping = 5,
lot_skills = 6,
lot_welcome = 7,
lot_games = 8,
lot_entertainment = 9,
lot_residence = 10,
avatar_most_famous = 11,
avatar_best_karma = 12,
avatar_friendliest = 13,
avatar_most_infamous = 14,
avatar_meanest = 15,
};
pub const UserReferenceType = enum(32) {
EA = 1,
MAXIS = 2,
MOMI = 3,
TSO = 4,
AVATAR = 5,
};

View file

@ -0,0 +1,34 @@
pub const CursorType = enum {
Normal,
ArrowUp,
ArrowUpLeft,
ArrowUpRight,
ArrowDown,
ArrowDownLeft,
ArrowDownRight,
ArrowLeft,
ArrowRight,
LiveNothing,
LiveObjectUnavail,
LivePerson,
IBeam,
SimsRotate,
SimsRotateNE,
SimsRotateSE,
SimsRotateSW,
SimsRotateNW,
SimsMove,
SimsPlace,
Hourglass,
LiveObjectAvail,
LiveObject1Star,
LiveObject2Star,
LiveObject3Star,
LiveObject4Star,
LiveObject5Star,
LiveObjectSpecial,
};

15
backup-src/config.zig Normal file
View file

@ -0,0 +1,15 @@
pub const Branding = struct {
logo: []const u8,
background: []const u8,
};
pub const Config = struct {
height: i64,
width: i64,
game_path: []const u8,
branding: *Branding,
pub fn init(self: Config) Config {
return self;
}
};

View file

@ -0,0 +1,27 @@
pub const Asset = struct {
Group: u32,
File: u32,
Type: u32,
};
pub const FileError = enum {
FERR_NOT_FOUND,
FERR_OPEN,
FERR_BLANK,
FERR_MEMORY,
FERR_READ,
FERR_UNRECOGNIZED,
FERR_INVALIDDATA,
};
pub const ImageFormat = enum {
FIMG_BGR24,
FIMG_BGRA32,
};
pub const Image = struct {
Width: u8,
Height: u8,
Format: ImageFormat,
Data: u8,
};

50
backup-src/io/oiff.zig Normal file
View file

@ -0,0 +1,50 @@
const std = @import("std");
const rl = @import("raylib");
pub const Texture = struct {
texture: []const u8,
buffer: []const u8,
};
pub const View = struct {
north: *Texture,
south: *Texture,
};
pub const Motives = struct {
room: i64, // Environment in later games
hunger: i64,
social: i64,
comfort: i64,
hygiene: i64,
fun: i64,
energy: i64,
bladder: i64,
};
pub const Skills = struct {
cooking: i64,
mechanical: i64,
charisma: i64,
body: i64,
logic: i64,
creativity: i64,
};
/// Open object format with similar
pub const OpenIff = struct {
name: []const u8,
description: []const u8,
version: i64,
catagory: []const u8,
/// Item to derive all logic from.
/// By defualt, this comes from the base game.
base: []const u8,
motives: *Motives,
skills: Skills,
views: *View,
// pub fn init(file: []const u8) OpenIff {
// }
};

234
backup-src/main.zig Normal file
View file

@ -0,0 +1,234 @@
const std = @import("std");
const rl = @import("raylib");
const world = @import("world.zig");
const nso = @import("niotso.zig");
const clap = @import("clap");
const dbg = std.debug;
const GameScreen = enum {
login,
cas, // Create-A-Sim
map, // city screen
lot, // world view
};
//We start that NorthWest so it is easy to determine the flip
const CardinalDirection = enum {
NorthWest, // 0, sprite 1
NorthEast, // 1, sprite 1 flip
SouthEast, // 2, sprite 2
SouthWest, // 3, sprite 2 flip
};
const Rotations = enum {
left, // 0
right, // 1
};
const RotationManager = struct {
Direction: CardinalDirection,
pub fn init(self: RotationManager) RotationManager {
return self;
}
pub fn rotate(self: *RotationManager, rotation: Rotations) void {
//rotate the direction by 90 degrees
var direction_index = @as(i8, @intFromEnum(self.Direction));
switch (rotation) {
.left => {
direction_index = direction_index - 1;
},
.right => {
direction_index = direction_index + 1;
},
}
// Circle around if out of bounds
if (direction_index < 0) {
self.Direction = CardinalDirection.SouthWest;
} else if (direction_index > 3) {
self.Direction = CardinalDirection.NorthWest;
} else {
self.Direction = @as(CardinalDirection, @enumFromInt(direction_index));
}
//Result
dbg.print("Orientation: {any}\n", .{self.Direction});
}
};
/// Still in the proof of concept phase, don't mind the mess
pub fn main() anyerror!void {
const screen_width = 800;
const screen_height = 600;
rl.initWindow(screen_width, screen_height, "My Simulation");
defer rl.closeWindow();
var current_screen: GameScreen = .login;
var frame_counter: i32 = 0;
// NOTE: jip
// I don't think we can get away with using the built-in camera
// We need pixel perfect isometric camera
var lot_camera = rl.Camera3D{
.position = rl.Vector3.init(-90.0, 20.0, 90.0),
.target = rl.Vector3.init(0, 0.0, 0),
.up = rl.Vector3.init(0, 1.0, 0),
.fovy = 10,
.projection = rl.CameraProjection.camera_orthographic,
};
var city_camera = rl.Camera3D{
.position = rl.Vector3.init(18.0, 21.0, 18),
.target = rl.Vector3.init(0, 0, 0),
.up = rl.Vector3.init(0, 1.0, 0),
.fovy = 45,
.projection = rl.CameraProjection.camera_perspective,
};
const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0);
const itemStatic = rl.Vector3.init(0.0, 1.0, 0.0);
const itemStaticSize = rl.Vector2.init(2.0, 2.0);
var rotation_manager = RotationManager.init(.{
.Direction = CardinalDirection.SouthEast,
});
rl.setTargetFPS(60);
const logo = rl.Texture.init("resources/logo.png");
const splash = rl.Texture.init("resources/tsosplash.png");
const chair1 = rl.Texture.init("resources/items/dorm/chair/chair_1.png");
const chair1_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair1.width)), @as(f32, @floatFromInt(chair1.height)));
const chair2 = rl.Texture.init("resources/items/dorm/chair/chair_2.png");
const chair2_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair2.width)), @as(f32, @floatFromInt(chair2.height)));
const city = rl.loadImage("resources/cities/city_0100/elevation.png");
// const city_texture = rl.Texture.init("resources/cities/city_0100/vertexcolor.png");
// TODO: figure out a better way to unload all images and textures.
defer {
rl.unloadTexture(splash);
rl.unloadTexture(logo);
rl.unloadTexture(chair1);
rl.unloadTexture(chair2);
rl.unloadImage(city);
}
const mesh = rl.genMeshHeightmap(city, rl.Vector3.init(16, 8, 16));
const model = rl.loadModelFromMesh(mesh);
// model.materials[0].maps[rl.MATERIAL_MAP_DIFFUSE].texture = city_texture;
while (!rl.windowShouldClose()) {
// Update
// ------------------
switch (current_screen) {
// Skip straight to lot view until city server is complete
.login => {
frame_counter += 1;
if (frame_counter > 120) current_screen = .lot;
},
// TODO: Write CAS (Create-A-Sim) screen
.cas => {},
.map => {},
.lot => {
const zoom_increment = 5;
// rotate with keyboard
if (rl.isKeyPressed(rl.KeyboardKey.key_s)) {
if (lot_camera.fovy == 10) {
lot_camera.fovy += zoom_increment;
}
dbg.print("Zoom level: {d}\n", .{
lot_camera.fovy,
});
} else if (rl.isKeyPressed(rl.KeyboardKey.key_w)) {
if (lot_camera.fovy == 15) {
lot_camera.fovy -= zoom_increment;
}
dbg.print("Zoom level: {d}\n", .{
lot_camera.fovy,
});
}
// roate with scrollwheel
const mouse_wheel_y = std.math.clamp(-rl.getMouseWheelMove(), -1, 1) * zoom_increment;
if (mouse_wheel_y != 0) {
const zoom_min = 10;
const zoom_max = 25;
lot_camera.fovy = std.math.clamp(lot_camera.fovy + mouse_wheel_y, zoom_min, zoom_max);
dbg.print("Zoom level: {d}\n", .{
lot_camera.fovy,
});
}
if (rl.isKeyPressed(rl.KeyboardKey.key_a)) {
lot_camera.position = rl.Vector3.init(-90.0, 20.0, 90.0);
rotation_manager.rotate(Rotations.left);
dbg.print("rotate left\n", .{});
} else if (rl.isKeyPressed(rl.KeyboardKey.key_d)) {
lot_camera.position = rl.Vector3.init(90.0, 20.0, 90.0);
rotation_manager.rotate(Rotations.right);
dbg.print("rotate right\n", .{});
}
// camera.update(rl.CameraMode.camera_custom);
},
}
// ------------------
// Draw
rl.beginDrawing();
defer rl.endDrawing();
switch (current_screen) {
// Mockup loading screen, skips straight to world
.login => {
// Splash screen
rl.drawTexture(splash, 0, 0, rl.Color.white);
rl.drawTexture(logo, screen_width / 2.0 - 240, 30, rl.Color.white);
// Loading text
rl.drawText("Reticulating splines...", 20, screen_height - 30, 20, rl.Color.white);
},
// Skip this for now
.cas => {},
.map => {
rl.clearBackground(rl.Color.sky_blue);
city_camera.begin();
defer city_camera.end();
rl.drawModel(model, floorLevel, 1.0, rl.Color.green);
},
// Low view (i.e. world)
.lot => {
rl.clearBackground(rl.Color.sky_blue);
lot_camera.begin();
defer lot_camera.end();
rl.drawPlane(floorLevel, rl.Vector2.init(64, 64), rl.Color.dark_green);
switch (rotation_manager.Direction) {
.NorthWest => {
rl.drawBillboardRec(lot_camera, chair1, chair1_rect, itemStatic, itemStaticSize, rl.Color.white);
},
.NorthEast => {
rl.drawBillboard(lot_camera, chair1, itemStatic, 2.0, rl.Color.white);
},
.SouthEast => {
rl.drawBillboard(lot_camera, chair2, itemStatic, 2.0, rl.Color.white);
},
.SouthWest => {
rl.drawBillboardRec(lot_camera, chair2, chair2_rect, itemStatic, itemStaticSize, rl.Color.white);
},
}
// rl.drawGrid(64, 1.0);
},
}
rl.drawFPS(10, 10);
}
}

9
backup-src/niotso.zig Normal file
View file

@ -0,0 +1,9 @@
pub usingnamespace @cImport({
@cInclude("./formats/iff/iff.h");
@cInclude("./formats/iff/iffparser.h");
@cInclude("./formats/far/far.h");
@cInclude("./formats/far/config.h");
@cInclude("./formats/cur/read_cur.h");
@cInclude("./formats/utk/read_utk.h");
@cInclude("./formats/xa/read_xa.h");
});

10
backup-src/root.zig Normal file
View file

@ -0,0 +1,10 @@
const std = @import("std");
const testing = std.testing;
export fn add(a: i32, b: i32) i32 {
return a + b;
}
test "basic add functionality" {
try testing.expect(add(3, 7) == 10);
}

View file

1
backup-src/version.txt Normal file
View file

@ -0,0 +1 @@
dev-0.88.101

3
backup-src/vitaboy.zig Normal file
View file

@ -0,0 +1,3 @@
const std = @import("std");
const rl = @import("raylib");
const fh = @import("./io/filehandler.zig");

77
backup-src/world.zig Normal file
View file

@ -0,0 +1,77 @@
const std = @import("std");
const rl = @import("raylib");
const Allocator = std.mem.Allocator;
const json = std.json;
const dbg = std.debug;
const fmt = std.fmt;
const fs = std.fs;
pub const Floor = struct {
level: i32,
x: f32,
y: f32,
value: i32,
};
pub const Wall = struct {
level: i32,
x: f32,
y: f32,
value: i32,
tls: i32,
trs: i32,
tlp: i32,
trp: i32,
blp: i32,
brp: i32,
};
pub const World = struct {
floors: []Floor,
walls: ?[]Wall,
};
pub const Item = struct {
guid: i32,
level: i32,
x: i32,
y: i32,
dir: i32,
group: i32,
};
pub const House = struct {
version: f32,
size: i32,
category: i32,
world: World,
items: []Item,
};
pub const Blueprint = struct {
house: House,
};
/// Draws floors from JSON Blueprint files
pub fn draw_floors(json_file: [:0]const u8) !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Load file
const lot = rl.loadFileText(json_file);
defer rl.unloadFileText(lot);
// Parse JSON
const parsed = try json.parseFromSlice(Blueprint, allocator, lot, .{});
defer parsed.deinit();
const blueprint = parsed.value;
const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0);
for (blueprint.house.world.floors) |flr| {
// Draw grass
rl.drawPlane(floorLevel, rl.Vector2.init(flr.x, flr.y), rl.Color.green);
}
}