Skip to content

Instantly share code, notes, and snippets.

View zacharycarter's full-sized avatar
👋

Tail Wag Games zacharycarter

👋
View GitHub Profile
curl --request POST \
--url http://localhost:8082/foo \
--header 'content-type: application/json' \
--data '{
"bar": "FOOBAR"
}'
import jester, asyncdispatch, os, osproc, strutils, json, threadpool, asyncfile
proc respondOnReady(fv: FlowVar[TaintedString], resp: Response) {.async.} =
while true:
if fv.isReady:
echo ^fv
var errorsFile = openAsync("tmp/errors.txt", fmReadWrite)
var logFile = openAsync("tmp/logfile.txt", fmReadWrite)
var errors = await errorsFile.readAll()
CL-USER> (load "/Users/zachcarter/Downloads/portacle/test.lisp")
<ERROR> [10:44:35] cl-bodge.host system.lisp (initialize-system :after host-system with-truncated-stack-lambda) -
Unhandled error:
arithmetic error FLOATING-POINT-OVERFLOW signalled
[Condition of type FLOATING-POINT-OVERFLOW]
#<ENVIRONMENT {100995DAA3}>
[Environment of thread #<THREAD "main thread" RUNNING {1003AC6453}>]
Available restarts:
# grassland area with cliffs, water, and some buildings
[Image]
img=images/tilesets/tileset_grassland.png
[Tiles]
# grass tiles (use in a 4x4 repeating grid for best results)
tile=16,0,0,64,32,32,16
tile=17,64,0,64,32,32,16
tile=18,128,0,64,32,32,16
tile=19,192,0,64,32,32,16
let animationFrame = getFrame(idleAnimation, zengine.clock.timeElapsed, 0.2)
# Draw object with solid color into render target
beginDrawing()
begin2dMode(camera)
clearBackground(TRANSPARENT)
beginTextureMode(target)
beginShaderMode(solidColorShader)
drawTexture(textureAtlas.texture, animationFrame.u, animationFrame.v, animationFrame.u2, animationFrame.v2, Rectangle(x: ((20 - 2) * 32) - 32, y: ((20 + 2) * 16) - 64, width: animationFrame.width, height: animationFrame.height), vec2f(0), 0.0, RED)
endShaderMode()
More or less you draw the object to the stencil buffer, then you draw the object with the color glow you want into a separate buffer. You then run a Gaussian blur on the separate buffer. Finally you render the blurred buffer onto the screen, restricted by the stencil buffer.
render the objects to be outlined so that they set a flag in the stencil buffer, fill the stencilled areas with the outline color in the offscreen buffer, do your blurring and add the results to the screen buffer.
1. Render all of your selected units into a render target the size of the screen using a shader just fills the unit with their selection color. This’ll let you do different selection colors for different types of units.
2. Render your scene normally into the back buffer.
3. Render all of your selected units into the stencil buffer without rendering into the color channels.
4. Render your selection image into the stenciled back buffer with a shader that performs a gaussian filter over the image. This’ll get you your blurry sten
# Draw object with solid color into render target
beginDrawing()
begin2dMode(camera)
clearBackground(TRANSPARENT)
let animationFrame = getFrame(idleAnimation, zengine.clock.timeElapsed, 0.2)
beginTextureMode(target)
beginShaderMode(solidColorShader)
drawTexture(textureAtlas.texture, animationFrame.u, animationFrame.v, animationFrame.u2, animationFrame.v2, Rectangle(x: ((20 - 2) * 32) - 32, y: ((20 + 2) * 16) - 64, width: animationFrame.width, height: animationFrame.height), vec2f(0), 0.0, RED)
endShaderMode()
endTextureMode()
beginDrawing()
begin2dMode(camera)
clearBackground(TRANSPARENT)
let animationFrame = getFrame(idleAnimation, zengine.clock.timeElapsed, 0.2)
beginTextureMode(target) # Create render target
beginShaderMode(solidColorShader) # Turn on solid color shader
# Draw texture to render target
drawTexture(textureAtlas.texture, animationFrame.u, animationFrame.v, animationFrame.u2, animationFrame.v2, Rectangle(x: ((20 - 2) * 32) - 32, y: ((20 + 2) * 16) - 64, width: animationFrame.width, height: animationFrame.height), vec2f(0), 0.0, RED)
endShaderMode()
zglEnableStencilTest()
glDepthMask(GL_FALSE)
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE)
var stencilBuffer: array[960 * 540, cuchar]
glStencilFunc(GL_EQUAL, 0, 1)
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE)
glStencilMask(1)
glClearStencil(1)
glClear(GL_STENCIL_BUFFER_BIT)
import math
const
even = 1
odd = -1
hexDirections = @[(1, 0, -1), (1, -1, 0), (0, -1, 1), (-1, 0, 1), (-1, 1, 0), (0, 1, -1)]
hexDiagonals = @[(2, -1, -1), (1, -2, 1), (-1, -1, 2), (-2, 1, 1), (-1, 2, -1), (1, 1, -2)]
type
Point = tuple[x,y: float]