aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig
index 2d12975..8129ae2 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -28,8 +28,8 @@ usingnamespace @import("raycast.zig");
usingnamespace @import("renderConstants.zig");
usingnamespace @import("map.zig");
-// TODO: is there anyway i can say fn renderWall : RenderWallFunction?
-fn renderWall(
+// TODO: is there anyway i can say fn renderSlice : RenderSliceFunction?
+fn renderSlice(
window: sf.graphics.RenderWindow,
sprite: sf.graphics.Sprite,
col: i32, // which column
@@ -77,13 +77,15 @@ pub fn main() !void {
var y: u32 = 0;
while (y < 32) : (y += 1) {
map.cells.items[y * 32 + 00] = Cell{ .height = MAX_HEIGHT };
- map.cells.items[y * 32 + 31] = Cell{ .height = MAX_HEIGHT };
+ map.cells.items[y * 32 + 31] = Cell{ .height = MAX_HEIGHT, .wall_texture = 2 };
map.cells.items[31 * 32 + y] = Cell{ .height = MAX_HEIGHT };
map.cells.items[00 * 32 + y] = Cell{ .height = MAX_HEIGHT };
}
- map.cells.items[y * 15 + 15] = Cell{ .height = MAX_HEIGHT, .wall_texture = 1 };
- map.cells.items[y * 15 + 14] = Cell{ .height = MAX_HEIGHT / 3, .wall_texture = 1, .floor_texture = 1 };
+ map.cells.items[32 * 15 + 15] = Cell{ .height = MAX_HEIGHT, .wall_texture = 1 };
+ map.cells.items[32 * 15 + 14] = Cell{ .height = MAX_HEIGHT / 3, .wall_texture = 1, .floor_texture = 1 };
+
+ try map.objects.append(Object{.pos_x = 14.5, .pos_y = 16.5, .texture = 0, .height = 1.5, .width = 1});
// Initialise SFML
//--------------------------------------------------------------------------
@@ -117,7 +119,15 @@ pub fn main() !void {
var walls_sprite = try sf.Sprite.createFromTexture(wall_textures);
defer walls_sprite.destroy();
- // Load floor textures
+ // Load sprite textures
+ var object_textures = try sf.Texture.createFromFile("objects.png");
+ defer object_textures.destroy();
+ object_textures.setSmooth(false);
+
+ var objects_sprite = try sf.Sprite.createFromTexture(object_textures);
+ defer objects_sprite.destroy();
+
+ // Load floor image
var floors_image = try sf.Image.createFromFile("floors.png");
defer floors_image.destroy();
@@ -187,7 +197,7 @@ pub fn main() !void {
window.draw(rendered_floors_sprite, null);
// Finally the world
- player.renderWorld(window, walls_sprite, map, renderWall);
+ player.renderWorld(window, walls_sprite, objects_sprite, renderSlice, map);
window.display();