1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: format most examples and tutorials, add them to v test-cleancode (#9826)

This commit is contained in:
Lukas Neubert
2021-04-20 16:16:35 +02:00
committed by GitHub
parent dff50686d6
commit 16e79bc3ca
38 changed files with 471 additions and 433 deletions

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT license file distributed with this software package
module particle
import vec2
import particle.vec2
import sokol.sgl
const (
@ -16,9 +16,9 @@ pub fn new(location vec2.Vec2) &Particle {
location: location
velocity: vec2.Vec2{0, 0}
acceleration: vec2.Vec2{0, 0}
color: default_v_color
life_time: default_life_time
life_time_init: default_life_time
color: particle.default_v_color
life_time: particle.default_life_time
life_time_init: particle.default_life_time
}
return p
}
@ -75,7 +75,7 @@ pub fn (mut p Particle) reset() {
p.acceleration.zero()
p.velocity.zero()
// p.color = Color{93, 136, 193, 255}
p.color = default_v_color
p.life_time = default_life_time
p.color = particle.default_v_color
p.life_time = particle.default_life_time
p.life_time_init = p.life_time
}

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT license file distributed with this software package
module particle
import vec2
import particle.vec2
import rand
import sokol.sgl
@ -14,8 +14,8 @@ pub struct System {
width int
height int
mut:
pool []&Particle
bin []&Particle
pool []&Particle
bin []&Particle
}
pub fn (mut s System) init(sc SystemConfig) {
@ -82,7 +82,7 @@ pub fn (mut s System) free() {
print(ptr_str(p) + ' ouch')
continue
}
unsafe {free(p)}
unsafe { free(p) }
}
s.pool.clear()
for p in s.bin {

View File

@ -20,7 +20,7 @@ pub fn (mut v Vec2) from(src Vec2) {
// * Addition
// + operator overload. Adds two vectors
pub fn (v1 Vec2) +(v2 Vec2) Vec2 {
pub fn (v1 Vec2) + (v2 Vec2) Vec2 {
return Vec2{v1.x + v2.x, v1.y + v2.y}
}
@ -43,7 +43,7 @@ pub fn (mut v Vec2) plus_f64(scalar f64) {
}
// * Subtraction
pub fn (v1 Vec2) -(v2 Vec2) Vec2 {
pub fn (v1 Vec2) - (v2 Vec2) Vec2 {
return Vec2{v1.x - v2.x, v1.y - v2.y}
}
@ -66,7 +66,7 @@ pub fn (mut v Vec2) subtract_f64(scalar f64) {
}
// * Multiplication
pub fn (v1 Vec2) *(v2 Vec2) Vec2 {
pub fn (v1 Vec2) * (v2 Vec2) Vec2 {
return Vec2{v1.x * v2.x, v1.y * v2.y}
}