top of page

INTRODUCING SPRITES

Controls: Esc - To quit game

Arrow Keys to give move direction to the sphere

WASD to change the rotation-axis of the cube

Move the camera

OU(Z-axis)

IK(Y-axis)

JL(X-axis)

Rotate the camera

YR(Z-axis)

TG(Y-axis)

FH(X-axis)

C/V to traverse cameras in the camera vector

 

You can see the two sprites in the top left and top right corner.

Below is one-sided triangle rendering vs both sided triangle rendering.

Below is depth buffer enabled vs depth buffer disabled.

This happens because the depth of the pixels get calculated incorrectly.

I implemented a gameobject2d class to create sprites. In that class I wrote a rect transform to denote the pixel coordinates from which the sprite is drawn and the width and the height of the sprite that is to be drawn. I also implemented something called as the anchor which basically denotes from which point the sprite will be drawn. Then I converted pixel coordinates to screen coordinates with respect to the anchor.

Below is a human readable effect file which contains all the three render states. They are represented by boolean values as they can be either on or off like status bits in a CPU register.

The three render state bits are represented using a single byte of data.

The best choice to place the render states bits in the binary effect file is at the start of the file. This is because it is the only constant size data in the file. The other pieces of data are variable in length.

The purpose of this assignment was to implement render states and add the capability of drawing sprites to our engine. I also did the optional requirement so that my sprites scale correctly. I wrote a gameobject2d builder and made the loading of sprites data driven by creating the necessary binary files. I also modified the cSprite class to use halves instead of floats for UVs thereby reducing the size of the cSprite class.

bottom of page