andrewrk / tetris Goto Github PK
View Code? Open in Web Editor NEWA simple tetris clone written in zig programming language.
License: MIT License
A simple tetris clone written in zig programming language.
License: MIT License
I just grabbed the 0.4.0 version of the linux compiler:
± |master ✓| → ~/apps/zig-linux-x86_64-0.4.0/zig version
0.4.0
When trying to build the master
branch following the README.md
, I get this error:
/home/phtrivier/perso/src/zig/tetris/build.zig:9:60: error: use of undeclared identifier '_'
exe.addCSourceFile("stb_image-2.22/stb_image_impl.c", [_][]const u8{"-std=c99"});
^
Am I missing something, or should I use a "master" version of the compiler ?
Hi,
I'm using zig version 0.0.0 on 64-bit Arch Linux.
$ zig version
0.0.0
When building tetris, I get the following error:
$ zig build src/main.zig --name tetris --export exe --library c --library m --library glfw --library epoxy --library png --library z
src/main.zig:2:17: error: no member named 'rand' in '/usr/lib/zig/std/index.zig'
const Rand = std.rand.Rand;
Best regards,
Alexander F Rødseth
I assume Andrew wants us to use this repo's code to get started on our own projects, but there should be a license to make that intention clear. Could an MIT or CC0 or some other license be added?
When building the game on linux-x86_64, i get the following LLVM error:
Call parameter type does not match function signature!
%Tetris* @tetris_state
i8* call void @glfwSetWindowUserPointer(i8* %62, %Tetris* @tetris_state), !dbg !12525
LLVM ERROR: Broken module found, compilation aborted!`
To fix this error I had to change the 'const' to a 'var' in main.zig:178.
I'm not sure if this is the correct solution, therefore this issue and not directly a PR.
Maybe this has something to do with this issue: ziglang/zig#2444
Btw, I'm FireFox317 on the IRC
I would like to refactor to separate the game logic from io in order to add ultibo as a replacement for glfw. Would you be amenable to pull requests for that kind of refactoring?
The first step is to start with a working build:
debian 9 x86/64:
root@localhost:~/github.com/andrewrk/tetris# zig build
/root/github.com/andrewrk/tetris/build.zig:12:71: error: container 'builtin' has no member called 'Environ'
exe.setTarget(builtin.Arch.x86_64, builtin.Os.windows, builtin.Environ.gnu);
^
root@localhost:~/github.com/andrewrk/tetris# zig version
0.3.0+5469e3e3
I have yet to build my zig hello world, so not quite sure how to fix this build error.
~/s/tetris (master) [1]> zig env
{
"zig_exe": "/Users/hyiltiz/.asdf/installs/zig/0.10.0/zig",
"lib_dir": "/Users/hyiltiz/.asdf/installs/zig/0.10.0/lib",
"std_dir": "/Users/hyiltiz/.asdf/installs/zig/0.10.0/lib/std",
"global_cache_dir": "/Users/hyiltiz/.cache/zig",
"version": "0.10.0",
"target": "x86_64-macos.13...13-none"
}
~/s/tetris (master)> pwd
/Users/hyiltiz/src/tetris
~/s/tetris (master)> zig build play
/Users/hyiltiz/.asdf/installs/zig/0.10.0/lib/std/build.zig:2314:31: error: deprecated; use addIncludePath
pub const addIncludeDir = @compileError("deprecated; use addIncludePath");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
build: /Users/hyiltiz/src/tetris/build.zig:25:8
runBuild: /Users/hyiltiz/.asdf/installs/zig/0.10.0/lib/build_runner.zig:230:22
remaining reference traces hidden; use '-freference-trace' to see all reference traces
don@oysters:~/src/tetris$ fg
zig build play
Build Dependencies...unwind [2] Compile C Objects [5/8] UnwindLevel1-gcc-ext.c..Build Dependencies...unwind [2] Compile C Objects [7/8] UnwindRegistersRestore.SBuild Dependencies...at_quick_exit [2] Compile C Objects [1/1] at_quick_exit.c..Build Dependencies...pthread_atfork [2] Compile C Objects [1/1] pthread_atfork.cBuild Dependencies...stack_chk_fail_local [2] Compile C Objects [1/1] stack_chk_Error: u8@7ffcfe884080
/home/don/src/tetris/src/main.zig:22:10: 0x22989f in errorCallback (tetris)
panic("Error: {}\n", .{description});
^
The following command terminated unexpectedly:
cd /home/don/src/tetris && /home/don/src/tetris/zig-cache/bin/tetris
Build failed. The following command failed:
/home/don/src/tetris/zig-cache/o/T43ZyUZTaP-cR0Ny_GS_98VEC-nkbfdu0f2TKyFcPbhrbS2oaCqceqlkSRHZhBey/build /usr/local/bin/zig /home/don/src/tetris /home/don/src/tetris/zig-cache play
don@oysters:~/src/tetris$ zig version
0.5.0+cf38ce970
Design constraints:
It looks like the video is private or deleted.
The game's name is trademaked, and the rights holders already issued DMCAs to projects on Github that used their name for promotion: https://github.com/search?q=repo%3Agithub%2Fdmca+tetris&type=pullrequests
Since this repo is still being updated and is referenced from time to time as an example of what Zig can do (= promotion) it's going to gather more attention, that said I think it would be safer to change the repo/project's name and any other reference in code, video titles or other promotional articles you may use in the future, to at least reduce the risk of a takedown.
The best thing would be to have a sample game which completely avoids legal gray areas, but the second best thing I guess is just being careful with names and hope for the best. Qt did something similar, of course it's not a bulletproof solution but it's something.
I'm a bit new to zig-lang, and a bit generally confused about things :]
I want to do a zig opengl app https://github.com/bfredl/zigui and it seems I can prototype stuff by copypasting stuff from this repo and just add whatever c dependencies I need. However, is there already a zig opengl app framework lib somewhere I could use instead? If not, I might separate my app in to two layers (opengl initialization lib + the actuall app), so that there is such a library. I guess I also should look though @ifreund stuff like https://github.com/ifreund/river, so to not reinvent anything that is already there there.
I have failed multiple times using the dependent version I downloaded and the dependent version I compiled myself.
版本 Windows 11 专业版
版本 21H2
操作系统版本 22000.318
zig version: 0.12.0-dev.414+461036069
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.