Git Product home page Git Product logo

mazewalker's Introduction

MazeWalker: An attempt at Raycasting

Mazewalker is a simple, not at all polished game or rather an experiment which uses raycating to create a pseudo 3d world/maze.

The maze is first generated in 2D form using Prim's randomised algorithm. Which means everytime we run the game we start with a new maze. Also everytime we reach a door the player is put into a newly generated maze. So in a way you can play this game or run this experiment infinitely.

Once the maze is generated, we apply raycasting to convert the 2D maze into a pseudo 3D world.

A glimpse of the generated world:

github_short.mp4

What is raycasting

Raycasting is one of the first 3D techniques that pushed the boundaries of 3D games. One of the very first games that employed this technique is Wolfenstein 3D by the famous id Software. It does not create a pure 3D world but rather a pseuo 3D world. It draws 2D textures on the screen in a very clever manner to create the illusion of a 3D world.

I will not dig deep into the technique here because there are numerous articles/blogs and youtube videos on the internet which explains this technique in great detail. I have tried to give an overview of the technique here

How to run

Make sure you have installed lua (5.4.3 preferred) and love2d on your system.

After that, open this repository in your terminal and run

/path/to/love ./

If you have placed love2d in your system path then you dont need to mention the full path.

Controls

w                       -       move forward
s                       -       move backward
a                       -       move left
d                       -       move right
left mouse button       -       Fire
move mouse              -       Change player/camera direction

What all I have used

I have used lua to create this game and the awesome lua based love2d library to render graphics on screen. love2d is a truly amazing framework which is very easy to use and learn.

As I have already mentioned, to generate the mazes I have used Prim's randomized algorithm. And to make sure wall's get different textures, I have used flood fill algorithm to assign different textures to different clusters of walls.

NOTE

The idea was not really to create a game but to explore raycasting hands on. Also the code is by no means perfect, on the contrary I would say its kind of messy and has some bugs. So if anyone is interested to take a dig at the code and want to play around with lua and love, PRs are always welcome.

References:

raycasting tutorials/articles

sprites and textures used:

mazewalker's People

Contributors

djmgit avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.