Circular Texture
Today I added a new little effect that only happens when you hit the wall. I might change it a little bit more to like fade in / out depending on how close you are to the wall but that's a "deciding tomorrow" kinda thing.
I wanted to write this tech post to describe how I made the texture i'm referring to and also tell you how to fade the opacity in / out to draw said generated texture onto a quad such that it looks like you drew a circle when sampling the texture. Video for visual help here: https://twitter.com/AndrewNReinke/status/1459223000549449731
To start, you will need to set a width and height. In my case, height = width = 1024
You'll want to have some notion of the origin being at 0,0 so you just halve height and width to get the max x,y bound, so 512,512.
Then, you have a loop that only fills pixels on every N iteration for the Y and continue on after that for about U iterations to make the lines on the horiztonal be more thick. For the X iterations, you'll have the same code only if you're not to be filling any color, so you check each X to see if it lines up with the N iteration.
So something like
for(y = 0; y < height; y++)
{
if((!(y % N)) || YCont)
{
if(!YCont){YCont = U;} else{YCont--;}
for(x = 0; x < width; x++)
{fill texels and use alpha obtained by distance check func}
}
else
{
for(x = 0; x < width; x++)
{
if((!(x % N)) || XCont)
{
if(!XCont){XCont = U;}else{XCont--;}
fill texel with alpha value or'd into color
}
else
{
fill with no color / alpha;
}
}
}
}
Alpha is gotten by taking current X and Y and subtracting by 512 (in my case) to then divide it by the 512 and 512 respectively. After, you'll get the squared magnitude of it (dot with itself) and subtract the result by 2.0; After you'll take the absolute value of that subtraction and multiply it by half 256 to get the current alpha value (since result of sub and abs will be a decimal, you'll get a percentage of max alpha but halved due to a mistake I think (so the X or Y sub first might be by max texture size and then you just sub 1 but i'm unsure since I haven't tested it yet and just thought of it lol)).
That's it! You can see the code in the video I posted if you want to get more clarification / just ask me in the comments and I will help!
Please let me know your thoughts on my game thus far! Thank you for reading and have an awesome day :]
Files
Get Funmi
Funmi
Rotate the boat in air to get a high score
Status | In development |
Author | AndrewNReinke |
Genre | Action |
Tags | 3D, Arcade, DRM Free, handmade-engine, High Score, Low-poly, Retro, Rotation, Singleplayer, Third Person |
Languages | English, Japanese |
More posts
- Steam ReleaseDec 24, 2021
- Lots Of Changes With Text and StuffNov 19, 2021
- Text Texture AtlasNov 16, 2021
- Very Smol FixNov 15, 2021
- Font GenerationNov 14, 2021
- Added Fade In / Out And New Particle SystemNov 13, 2021
- I Wrote This Technique Thingy While Being Really Tired lmaoNov 11, 2021
- Collapsing UI Code Into One PipeNov 09, 2021
- Fixed Timers & Collision Volume BugsNov 08, 2021
Leave a comment
Log in with itch.io to leave a comment.