laaustin.blogg.se

How to create your own game engine in notepad
How to create your own game engine in notepad




how to create your own game engine in notepad

More precisely we need to explain what is this project() function, and what are these dx and dy arguments. var Vertex = function ( x, y, z ) // Close the path and draw the face

how to create your own game engine in notepad

Here we create a class to store the coordinates of the vertex. To represent a vertex, we need the right structure. Then, this shape will list its faces, and each face will list its vertices. We will begin by storing each vertex of our shape. To identify a square, for example, you call it ABCD, with A, B, C and D referring to vertices that make up each corner of the square.įor our 3D engine, it will be the same. You surely already did some basic geometry during your school years. To guess how to store a polyhedron, we have to remember how such a thing can be identified in maths. It’s not surprising when we talk about a shape that is already a polyhedron, like a cube, but it’s something to keep in mind when we want to display other shapes, like a sphere. In 3D, it’s the same thing and every shape must be approached with the 3D equivalent of a polygon: a polyhedron (a 3D shape in which we only find flat faces ant not curved sides as in a sphere).

how to create your own game engine in notepad

You can approach it by drawing a regular polygon with a lot of edges: the more edges you have, the more “perfect” is your circle. For example, you can’t display a perfect circle on a screen. The virtual world differs from the real one in one major way: nothing is continuous, and everything is discrete. Storing and Transforming 3D Shapes All Shapes Are Polyhedrons






How to create your own game engine in notepad