Skip to content

Ocawesome101/wolf-cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

// WOLF-CC
A simple raycasting engine for CraftOS-PC's graphics mode.  Turning into a bit of a Wolf3D clone.

✨featured on the CraftOS-PC home page!✨

Controls:
  W/S/Up/Down: move forwards/backwards
  A/D: strafe left/right
  Left/Right: turn left/right
  Space: open doors
  Left or Right Alt: shoot

If input lag becomes an issue, lower the key repeat interval in your system settings.  Even at 25 repeats/sec I sometimes experience issues when rendering lots of sprites.  I recommend 5 or less for an optimal experience.

Sprite rendering is NOT fast.

Maps are loaded from files in the `maps/` directory.  These can be created and modified with the included map editor.  See `MAPS` below for details in the format.

See `TODO` for future plans.

// TEXTURES
Texture files use a custom image format.  The first two bytes of the file specify the length of its palette section.  For each 4-byte entry in this palette section, there is 1 byte specifiying the palette index that this color occupies, then the RGB value of the color.  The palette is unique to each texture.  Combined, all loaded textures must not use any more than 256 unique colors due to limitations of CraftOS-PC's graphics mode.

After the palette comes the texture data.  This is a 4096-byte area, with each byte specifying the index in the texture's palette that is the color for that pixel.  This is converted upon load into a global palette index.  Similar colors are automatically matched, so that slight variations in color are discarded.

To convert a PNG file into a TEX file, if you have ImageMagick installed, you may run the following command in a Bourne-style shell:

  stream -map rgb FILE.png - | lua src-textures/raw2tex.lua > FILE.tex

To add or modify a game texture, edit one of the textures contained in `src-textures` in thes repo.  It must be a 64x64 PNG file.  Run the `conv.sh` shell script to convert all the textures in the `src-textures` folder into game textures.  It will automatically place them into the correct folder.

To load a texture, add a `loadTexture()` call with a unique texture index and the filename of the texture after line 111 in `main.lua`.  For example,

  loadTexture(5, "bluestone.tex")

loads the texture file `textures/bluestone.tex` as texture 5.  Texture 0 is unusable.  There may be no more than 256 colors.

// MAPS
The engine uses a very simple, custom world format similar to the texture format.  The first four bytes specify the respective width and height as unsigned, little-endian 16-bit numbers.  The next section of the file specifies the texture palette of that map.  This section is composed of length-prefixed string-ID pairs - one byte for the length of the texture name, including a one-byte ID, and then the texture data.  After this section, there is a section of length (w*h) where each byte is a texture ID.

The first two bits of this byte specify it as a door (if the first bit is set), or a sprite (if the second is set).  If either both or neither are set, the tile is just a regular tile.

About

A raycasting engine for CraftOS-PC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published