swisschili / cog Goto Github PK
View Code? Open in Web Editor NEWa 3d game rendered in the terminal with raycasting
a 3d game rendered in the terminal with raycasting
======= cog ======= an experimental 3d roguelike game written in c. ~~~~~~~~~~~~~~~~~~~ technology used ~~~~~~~~~~~~~~~~~~~ 3d rendering is done via raycasting. this is not the same as ray tracing, in fact it is far more efficient, with severe technical limitations in terms of what can be rendered. it was pioneered by wolfenstien 3d, the first game (that i know of) to use this rendering technique. basically the way it works is the map is a grid of either nothing (' ') or a wall ('#'). for example, consider this map: +-----------+ |#####=#####| |# #| |# ## @ #| |###########| +-----------+ (the |, -, and + outlines serve simply as a demonstration, they are meaningless.) the @ symbol represents the player character (in typical roguelike fashion). let's say the player is looking in the direction of the door ('='), this would be rendered by casting a ray outwards from the players position for each column of the view (terminal cell). once it colides with some wall, the distance from the player is recorded, and used to render a column of cells on the screen with an appropriate height. ~~~~~~~~ maps ~~~~~~~~ cog maps are stored as ascii encoded text files. they translate literally to the map that will be rendered by cog. the diagram above demonstrating rendering, is in fact, a valid map. large maps are split into "chunks" and rendered in different map buffers (see map.h). +-----------+ | example | +-----------+ the following ascii could be copy and pasted into a map file (unindented), and it should work: ################## ##### # ##### # #### # # # # @ # # # # # ############################# +-------+ | chars | +-------+ each character in a map means something, most of these are yet to be implemented, but here's what they will mean in the end: # wall @ player = door a-z teleport A-Z corresponding teleport exit ~~~~~~~~~~~~ building ~~~~~~~~~~~~ run make to build cog. by default it will also run the program. the binary will be located in dist/cog. $ make to build a production build (optimized compilation, stripped debug functions) set the BUILD variable to production in the makefile $ make BUILD=production ~~~~~~~~~~~~~~~~ dependencies ~~~~~~~~~~~~~~~~ ncurses: # dnf install ncurses-devel
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.