Share your repls and programming experiences

← Back to all posts
C++ Game Engine, Build 0.0.1
MatthewWesolows (35)

Edit

I've decided to list some features I hope to include in the next public share of the engine. I've also decided the name for my engine! The Cross Engine, I picked this because I'm Catholic, and the cross is pretty well known. I will continue to post updates and progress for every release. Feel free to comment any Ideas!

Release: Cross Engine Build 0.1.0
Next release time (hopefully): Sometime in the beginning of July
New Stuff I hope to add:

  • Bug Fixes
  • Portal Rendering
  • Better code management.
  • More Modular drawing functions
    Keep in mind that none of this is a guarantee, It's just what I hope to do.

Hi All!

Through lots of math, prayer, research, and a lot of paper, I wrote a super basic game engine for Repl.it. (Only available in C++ tho). Presented to you in square format. Use left and right arrows to look left and right respectively, and use WASD to move.

Lets Take It Back A Bit...

Replit has a lot of python programmers. Like A LOT of them. Thats great and all, but that means the replit devs mainly focus on up-to-datedness of Python. There's absolutely nothing wrong with that however, as its the job of the amazing replit devs to keep their community thriving. If they spent their time updating say, lolcode instead of Java, that would be bad. A lot of people make repls with HTML or Python or Node.js. The raw power of C++ is not up for display, which is why I decided to display it. I began to make plans for a game engine. Unfortunately, school was still in session, and with COVID 19, it was harder for me to focus on programming. What I mainly got done during the school season was math. Lots, and lots, of math. Im not the best at it, but I was decent. I started out with the motherload of all things graphic: the DOOM 1993 code (Its open source and available on Github if you'd like to take a look :) ). I learned BSP trees, portal rendering, and most importantly got a feel for how to combine maths and graphics.

I Hate Projection

When getting to the actual code, I realized that this was a lot harder than I first thought. Because Replit is not the fastest when it comes to runtime coupled with the fact that I was using SFML, I had to focus on speed. Which meant no ray-casting. There was a faster but harder option called Perspective Projection. This was the hardest thing for me. Most people would rationally use a projection matrix as a black box (<- check out the comment by fuzzyastrocat on why I was wrong there.), but since I was willing to cut corners, (no sloped walls, sprites instead of 3d objects, etc.) I used good ol' precalculus and algebra.

Lines, too many lines!

Lines were cheap, easy, and made clipping a lot easier (er... not really). I planned to define things like portals, walls, etc. in a 2d formant as lines or points. But because the game operates on a z-axis, I need to find a way to include that as well. Using 3 variables in the equation would overcomplicate things, so I decided to use equations in the format z = mx + b and y = mz + b. This way I could still get that sweet sweet linear formant and include all 3 axis. I'd like to explain the math more in depth, but I also want to keep this short.

End

Might as well go over the version format for the engine (the 0.0.1). the first digit acknowledges a stable and complete version (that may or may not be bug free) with an overhaul of features. For example 1.0.0 represents the first full release of the engine with all the goodies I hope to put in. the second digit represents an unstable experimental version of the engine. 1.1.0 may have some new and cool features, but it will probably be a bit buggy. The third digit is a test version that follows the rule: if it works, thats what matters. It'll most likely be bug filled and slow, with horrible code management, but it works. For example, 1.0.1 may have some extra small new thing, but it probably wont work half the time.

Bugs

Currently I know of one bug where the square disappears when the edges of off screen. However please report any bugs you may also find. I guess I could do something small like put your username in a contributors file or something.

Thanks for reading... Have a Great Day!

THANKS TO @SPQR FOR GETTING SFML TO WORK!!!!

Comments
hotnewtop
MatthewWesolows (35)

@Whippingdot Thanks, I'm glad you liked this!

EdwardBentler (40)

That's amazing, I always think of console-based languages as ... well, restricted to consoles, so I used them as such, but this is so great! Keep up the amazing work (please).

MatthewWesolows (35)

@EdwardBentler No worries! I plan to continue to add features to the engine, it just might take a while since I have other responsibilities. I'm really glad you liked this though!

fuzzyastrocat (1867)

Nicely done. (I agree that I wish more languages got the attention they deserve on here... I'd rant about how Python is essentially worthless as a modern programming language, but I don't think that'd be useful :D)

One thing tho...

use a projection matrix as a black box

Arghhh, it's not! I used to think that too, until I read into it more and realized how simple it is. It's actually very reasonably derivable with just algebra... there's an article somewhere on here about it, which I can't seem to find, but this one and this one seem to be similar. tl;dr, it's just the position of the camera, the rotation of the camera and the scale.

MatthewWesolows (35)

@fuzzyastrocat Huh, I guess I was wrong... I heard from multiple people that the projection matrix is like a black box. Thanks for correcting me though! I did use algebra for the perspective though, as you will see in the 'g_LoadSector' function. I struggled for a while until i figured out that you can get a linear equation for the point relative to the camera and plug in a value that gives a range between -1 and 1 (only after translating, clipping and rotating). I do agree with the fact that Python is essentially worthless since it is slow and promotes bad programming practice. I've always thought of it as a blueprint language to sketch out ideas before implementing it in a better language. I appreciate you taking the time to correct me!

DynamicSquid (5027)

Awesome! Great to see SFML on here :)

Coder100 (18925)

np!
and sfml

wow
you will have to link me the repl you found! @MatthewWesolows

MatthewWesolows (35)

@Coder100 Here ya go :D :
https://replit.com/@SPQR/SFML-Template?v=1
I'd advise checking out SPQR entire page, he's got some really clever and cool stuff!