weapon recoil
This commit is contained in:
+11
-6
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import "core:fmt"
|
||||
import "core:math"
|
||||
import "core:math/rand"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
move :: proc(t: ^Transform, x, y: f32) {
|
||||
@@ -17,18 +19,21 @@ move :: proc(t: ^Transform, x, y: f32) {
|
||||
shoot :: proc(t: Transform, pos: rl.Vector2) {
|
||||
pos_centered := center_to_grid(pos)
|
||||
t_centered := center_to_grid(t.position)
|
||||
spray: rl.Vector2 = {
|
||||
pos.x + rand.float32_range(0, CELL_SIZE),
|
||||
pos.y + rand.float32_range(0, CELL_SIZE),
|
||||
}
|
||||
line_particle := LineParticle {
|
||||
pos1 = t.position * CELL_SIZE + 10,
|
||||
pos2 = pos + 10,
|
||||
pos2 = spray,
|
||||
tint = rl.WHITE,
|
||||
lifetime = 0.2,
|
||||
}
|
||||
spawn_particle(line_particle)
|
||||
start_timer(1, test_timer_callback)
|
||||
}
|
||||
|
||||
test_timer_callback :: proc() {
|
||||
fmt.println("timer finished")
|
||||
if player.weapon.cooldown == true {return}
|
||||
player.weapon.cooldown = true
|
||||
start_timer(60 / player.weapon.rpm, proc() {player.weapon.cooldown = false})
|
||||
spawn_particle(line_particle)
|
||||
}
|
||||
|
||||
center_to_grid :: proc(pos: rl.Vector2) -> rl.Vector2 {
|
||||
|
||||
Reference in New Issue
Block a user