mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: use math.vec
in examples/sokol/particles (#16780)
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by an MIT license file distributed with this software package
|
||||
module particle
|
||||
|
||||
import particle.vec2
|
||||
import math.vec
|
||||
import rand
|
||||
import sokol.sgl
|
||||
|
||||
@ -22,7 +22,7 @@ pub fn (mut s System) init(sc SystemConfig) {
|
||||
unsafe { s.pool.flags.set(.noslices | .noshrink) }
|
||||
unsafe { s.bin.flags.set(.noslices | .noshrink) }
|
||||
for i := 0; i < sc.pool; i++ {
|
||||
p := new(vec2.Vec2{f32(s.width) * 0.5, f32(s.height) * 0.5})
|
||||
p := new(vec.Vec2[f64]{f32(s.width) * 0.5, f32(s.height) * 0.5})
|
||||
s.bin << p
|
||||
}
|
||||
}
|
||||
@ -69,16 +69,16 @@ pub fn (mut s System) reset() {
|
||||
|
||||
pub fn (mut s System) explode(x f32, y f32) {
|
||||
mut reserve := 500
|
||||
center := vec2.Vec2{x, y}
|
||||
center := vec.Vec2[f64]{x, y}
|
||||
mut p := &Particle(0)
|
||||
mut moved := 0
|
||||
for i := 0; i < s.bin.len && reserve > 0; i++ {
|
||||
p = s.bin[i]
|
||||
p.reset()
|
||||
p.location.from(center)
|
||||
p.acceleration = vec2.Vec2{rand.f32_in_range(-0.5, 0.5) or { -0.5 }, rand.f32_in_range(-0.5,
|
||||
p.acceleration = vec.Vec2[f64]{rand.f32_in_range(-0.5, 0.5) or { -0.5 }, rand.f32_in_range(-0.5,
|
||||
0.5) or { -0.5 }}
|
||||
p.velocity = vec2.Vec2{rand.f32_in_range(-0.5, 0.5) or { -0.5 }, rand.f32_in_range(-0.5,
|
||||
p.velocity = vec.Vec2[f64]{rand.f32_in_range(-0.5, 0.5) or { -0.5 }, rand.f32_in_range(-0.5,
|
||||
0.5) or { -0.5 }}
|
||||
p.life_time = rand.f64_in_range(500, 2000) or { 500 }
|
||||
s.pool << p
|
||||
|
Reference in New Issue
Block a user