-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Flame effect behind player's ship
- Loading branch information
1 parent
f6657d0
commit 214f375
Showing
4 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const std = @import("std"); | ||
const raylib = @import("raylib"); | ||
const Shared = @import("../Shared.zig").Shared; | ||
|
||
pub const Flames = struct { | ||
var frame: f32 = 0; | ||
|
||
pub inline fn Draw( | ||
position: raylib.Rectangle, | ||
rotation: f32, | ||
) void { | ||
if (frame == std.math.floatMax(f32)) { | ||
frame = 0; | ||
} | ||
frame += raylib.getFrameTime(); | ||
|
||
const fireTexture = Shared.Texture.Get(.Fire); | ||
|
||
const waveShader = Shared.Shader.Get(.Wave); | ||
const waveShaderLoc = raylib.getShaderLocation(waveShader, "seconds"); | ||
raylib.setShaderValue(waveShader, waveShaderLoc, &frame, @intFromEnum(raylib.ShaderUniformDataType.shader_uniform_float)); | ||
waveShader.activate(); | ||
defer waveShader.deactivate(); | ||
|
||
raylib.drawTexturePro( | ||
fireTexture, | ||
raylib.Rectangle.init( | ||
0, | ||
0, | ||
@as(f32, @floatFromInt(fireTexture.width)), | ||
@as(f32, @floatFromInt(fireTexture.height)), | ||
), | ||
position, | ||
raylib.Vector2.init(position.width / 2, position.height), | ||
rotation, | ||
Shared.Color.White.alpha(0.75), | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.