mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: unify const names to snake_case
This commit is contained in:
@ -6,16 +6,16 @@ import gx
|
||||
import automaton
|
||||
|
||||
const (
|
||||
screenWidth = 800
|
||||
screenHeight = 600
|
||||
filled_color = gx.Blue
|
||||
screen_width = 800
|
||||
screen_height = 600
|
||||
filled_color = gx.blue
|
||||
)
|
||||
|
||||
fn new_graphics() &gg.GG {
|
||||
glfw.init_glfw()
|
||||
return gg.new_context(gg.Cfg{
|
||||
width: screenWidth
|
||||
height: screenHeight
|
||||
width: screen_width
|
||||
height: screen_height
|
||||
use_ortho: true
|
||||
create_window: true
|
||||
resizable: false
|
||||
@ -49,7 +49,7 @@ fn main() {
|
||||
gg.post_empty_event() // needed so the animation does not stop
|
||||
///////////////////////////////////////////////
|
||||
a.update()
|
||||
print_automaton(a)
|
||||
print_automaton(a)
|
||||
graphics.render()
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
// hanoi tower
|
||||
const (
|
||||
Num = 7
|
||||
num = 7
|
||||
)
|
||||
|
||||
fn main() {
|
||||
hanoi(Num, 'A','B','C')
|
||||
hanoi(num, 'A','B','C')
|
||||
}
|
||||
|
||||
fn move(n int, a, b string) int {
|
||||
|
@ -7,8 +7,8 @@ import glfw
|
||||
import math
|
||||
|
||||
const (
|
||||
Size = 700
|
||||
Scale = 50.0
|
||||
size = 700
|
||||
scale = 50.0
|
||||
pi = math.pi
|
||||
)
|
||||
|
||||
@ -19,8 +19,8 @@ struct Context {
|
||||
fn main() {
|
||||
glfw.init_glfw()
|
||||
gconfig := gg.Cfg {
|
||||
width: Size
|
||||
height: Size
|
||||
width: size
|
||||
height: size
|
||||
use_ortho: true
|
||||
create_window: true
|
||||
window_title: 'Graph builder'
|
||||
@ -41,9 +41,9 @@ fn main() {
|
||||
|
||||
[live]
|
||||
fn (ctx &Context) draw() {
|
||||
center := f64(Size / 2)
|
||||
ctx.gg.draw_line(0, center, Size, center, gx.gray) // x axis
|
||||
ctx.gg.draw_line(center, 0, center, Size, gx.gray) // y axis
|
||||
center := f64(size / 2)
|
||||
ctx.gg.draw_line(0, center, size, center, gx.gray) // x axis
|
||||
ctx.gg.draw_line(center, 0, center, size, gx.gray) // y axis
|
||||
atime := f64( time.ticks() / 10 )
|
||||
stime := math.sin( 2.0 * pi * f64( time.ticks() % 6000 ) / 6000 )
|
||||
mut y := 0.0
|
||||
@ -58,8 +58,8 @@ fn (ctx &Context) draw() {
|
||||
//y = (x + 3) * (x + 3) / stime + stime*2.5
|
||||
//y = math.sqrt(30.0 - x * x) * stime
|
||||
//y -= (stime-0.5) + stime
|
||||
ctx.gg.draw_rect(center + x * Scale, center - y * Scale, 1, 1, gx.Blue)
|
||||
ctx.gg.draw_rect(center + x * Scale, center + y * Scale, 1, 1, gx.Red)
|
||||
ctx.gg.draw_rect(center + x * scale, center - y * scale, 1, 1, gx.blue)
|
||||
ctx.gg.draw_rect(center + x * scale, center + y * scale, 1, 1, gx.red)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
import os
|
||||
|
||||
const (
|
||||
NUMERIC_CHAR = [`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`.`,`e`,`E`]
|
||||
numeric_char = [`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`.`,`e`,`E`]
|
||||
)
|
||||
|
||||
// Convert expression to Reverse Polish Notation.
|
||||
@ -17,7 +17,7 @@ fn expr_to_rev_pol(expr string) ?[]string {
|
||||
mut pos := 0
|
||||
for pos<expr.len {
|
||||
mut end_pos := pos
|
||||
for end_pos<expr.len && expr[end_pos] in NUMERIC_CHAR {
|
||||
for end_pos<expr.len && expr[end_pos] in numeric_char {
|
||||
end_pos++
|
||||
}
|
||||
if end_pos>pos {
|
||||
@ -102,7 +102,7 @@ fn eval_rev_pol(rev_pol []string) ?f64 {
|
||||
|
||||
fn is_num_string(str string) bool {
|
||||
for c in str {
|
||||
if c !in NUMERIC_CHAR {
|
||||
if c !in numeric_char {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
import math
|
||||
|
||||
const (
|
||||
SolarMass = 39.47841760435743197 //4.0 * math.Pi * math.Pi
|
||||
DaysPerYear = 365.24
|
||||
N = 5
|
||||
solar_mass = 39.47841760435743197 //4.0 * math.Pi * math.Pi
|
||||
days_per_year = 365.24
|
||||
c_n = 5
|
||||
)
|
||||
|
||||
struct Position {
|
||||
@ -33,12 +33,12 @@ pub mut:
|
||||
}
|
||||
|
||||
fn advance(sys mut System, dt f64) {
|
||||
for i in 0..N - 1 {
|
||||
for i in 0..c_n - 1 {
|
||||
mut _vx := sys.v[i].x
|
||||
mut _vy := sys.v[i].y
|
||||
mut _vz := sys.v[i].z
|
||||
|
||||
for j := i + 1; j < N; j++ {
|
||||
for j := i + 1; j < c_n; j++ {
|
||||
dx := sys.s[i].x - sys.s[j].x
|
||||
dy := sys.s[i].y - sys.s[j].y
|
||||
dz := sys.s[i].z - sys.s[j].z
|
||||
@ -61,7 +61,7 @@ fn advance(sys mut System, dt f64) {
|
||||
sys.v[i].z = _vz
|
||||
}
|
||||
|
||||
for i in 0..N {
|
||||
for i in 0..c_n {
|
||||
sys.s[i].x += dt * sys.v[i].x
|
||||
sys.s[i].y += dt * sys.v[i].y
|
||||
sys.s[i].z += dt * sys.v[i].z
|
||||
@ -73,21 +73,21 @@ fn offsetmomentum(sys mut System) {
|
||||
mut py := f64(0)
|
||||
mut pz := f64(0)
|
||||
|
||||
for i in 0..N {
|
||||
for i in 0..c_n {
|
||||
px += sys.v[i].x * sys.v[i].m
|
||||
py += sys.v[i].y * sys.v[i].m
|
||||
pz += sys.v[i].z * sys.v[i].m
|
||||
}
|
||||
sys.v[0].x = -px / SolarMass
|
||||
sys.v[0].y = -py / SolarMass
|
||||
sys.v[0].z = -pz / SolarMass
|
||||
sys.v[0].x = -px / solar_mass
|
||||
sys.v[0].y = -py / solar_mass
|
||||
sys.v[0].z = -pz / solar_mass
|
||||
}
|
||||
|
||||
fn energy(sys System) f64 {
|
||||
mut e := f64(0)
|
||||
for i in 0..N {
|
||||
for i in 0..c_n {
|
||||
e += 0.5 * sys.v[i].m * (sys.v[i].x * sys.v[i].x + sys.v[i].y * sys.v[i].y + sys.v[i].z * sys.v[i].z)
|
||||
for j := i + 1; j < N; j++ {
|
||||
for j := i + 1; j < c_n; j++ {
|
||||
dx := sys.s[i].x - sys.s[j].x
|
||||
dy := sys.s[i].y - sys.s[j].y
|
||||
dz := sys.s[i].z - sys.s[j].z
|
||||
@ -100,11 +100,11 @@ fn energy(sys System) f64 {
|
||||
|
||||
fn arr_momentum() []Momentum {
|
||||
return [
|
||||
Momentum {0.0, 0.0, 0.0, SolarMass},
|
||||
Momentum {1.66007664274403694e-03 * DaysPerYear, 7.69901118419740425e-03 * DaysPerYear, -6.90460016972063023e-05 * DaysPerYear, 9.54791938424326609e-04 * SolarMass},
|
||||
Momentum {-2.76742510726862411e-03 * DaysPerYear, 4.99852801234917238e-03 * DaysPerYear, 2.30417297573763929e-05 * DaysPerYear, 2.85885980666130812e-04 * SolarMass},
|
||||
Momentum {2.96460137564761618e-03 * DaysPerYear, 2.37847173959480950e-03 * DaysPerYear, -2.96589568540237556e-05 * DaysPerYear, 4.36624404335156298e-05 * SolarMass},
|
||||
Momentum {2.68067772490389322e-03 * DaysPerYear, 1.62824170038242295e-03 * DaysPerYear, -9.51592254519715870e-05 * DaysPerYear, 5.15138902046611451e-05 * SolarMass},
|
||||
Momentum {0.0, 0.0, 0.0, solar_mass},
|
||||
Momentum {1.66007664274403694e-03 * days_per_year, 7.69901118419740425e-03 * days_per_year, -6.90460016972063023e-05 * days_per_year, 9.54791938424326609e-04 * solar_mass},
|
||||
Momentum {-2.76742510726862411e-03 * days_per_year, 4.99852801234917238e-03 * days_per_year, 2.30417297573763929e-05 * days_per_year, 2.85885980666130812e-04 * solar_mass},
|
||||
Momentum {2.96460137564761618e-03 * days_per_year, 2.37847173959480950e-03 * days_per_year, -2.96589568540237556e-05 * days_per_year, 4.36624404335156298e-05 * solar_mass},
|
||||
Momentum {2.68067772490389322e-03 * days_per_year, 1.62824170038242295e-03 * days_per_year, -9.51592254519715870e-05 * days_per_year, 5.15138902046611451e-05 * solar_mass},
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ fn (sp Sphere) intersect (r Ray) f64 {
|
||||
* The sphere fileds are: Sphere{radius, position, emission, color, material}
|
||||
******************************************************************************/
|
||||
const (
|
||||
Cen = Vec{50, 40.8, -860} // used by scene 1
|
||||
cen = Vec{50, 40.8, -860} // used by scene 1
|
||||
spheres = [
|
||||
[// scene 0 cornnel box
|
||||
Sphere{rad: 1e+5, p: Vec{ 1e+5 +1,40.8,81.6} , e: Vec{} , c: Vec{.75,.25,.25} , refl: .diff},//Left
|
||||
@ -183,7 +183,7 @@ spheres = [
|
||||
[// scene 1 sunset
|
||||
Sphere{rad: 1600, p: Vec{1.0,0.0,2.0}.mult_s(3000), e: Vec{1.0,.9,.8}.mult_s(1.2e+1*1.56*2) , c: Vec{} , refl: .diff}, // sun
|
||||
Sphere{rad: 1560, p: Vec{1,0,2}.mult_s(3500) , e: Vec{1.0,.5,.05}.mult_s(4.8e+1*1.56*2) , c: Vec{} , refl: .diff}, // horizon sun2
|
||||
Sphere{rad: 10000, p: Cen+Vec{0,0,-200}, e: Vec{0.00063842, 0.02001478, 0.28923243}.mult_s(6e-2*8), c: Vec{.7,.7,1}.mult_s(.25), refl: .diff}, // sky
|
||||
Sphere{rad: 10000, p: cen+Vec{0,0,-200}, e: Vec{0.00063842, 0.02001478, 0.28923243}.mult_s(6e-2*8), c: Vec{.7,.7,1}.mult_s(.25), refl: .diff}, // sky
|
||||
|
||||
Sphere{rad: 100000, p: Vec{50, -100000, 0} , e: Vec{} , c: Vec{.3,.3,.3} , refl: .diff}, // grnd
|
||||
Sphere{rad: 110000, p: Vec{50, -110048.5, 0} , e: Vec{.9,.5,.05}.mult_s(4) , c: Vec{}, refl: .diff},// horizon brightener
|
||||
|
@ -2,16 +2,16 @@ import time
|
||||
import rand
|
||||
|
||||
const (
|
||||
LEN = 1000 // how many random numbers to generate
|
||||
MAX = 10000 // max of the generated numbers
|
||||
gen_len = 1000 // how many random numbers to generate
|
||||
gen_max = 10000 // max of the generated numbers
|
||||
)
|
||||
|
||||
fn main() {
|
||||
rand.seed(time.now().unix)
|
||||
rand.next(MAX) // skip the first
|
||||
rand.next(gen_max) // skip the first
|
||||
mut arr := []int{}
|
||||
for _ in 0..LEN {
|
||||
arr << rand.next(MAX)
|
||||
for _ in 0..gen_len {
|
||||
arr << rand.next(gen_max)
|
||||
}
|
||||
println('length of random array is $arr.len')
|
||||
println('before quick sort whether array is sorted: ${is_sorted(arr)}')
|
||||
|
@ -22,26 +22,26 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
BlockSize = 20 // pixels
|
||||
FieldHeight = 20 // # of blocks
|
||||
FieldWidth = 10
|
||||
block_size = 20 // pixels
|
||||
field_height = 20 // # of blocks
|
||||
field_width = 10
|
||||
tetro_size = 4
|
||||
WinWidth = BlockSize * FieldWidth
|
||||
WinHeight = BlockSize * FieldHeight
|
||||
TimerPeriod = 250 // ms
|
||||
TextSize = 12
|
||||
LimitThickness = 3
|
||||
win_width = block_size * field_width
|
||||
win_height = block_size * field_height
|
||||
timer_period = 250 // ms
|
||||
text_size = 12
|
||||
limit_thickness = 3
|
||||
)
|
||||
|
||||
const (
|
||||
text_cfg = gx.TextCfg{
|
||||
align:gx.align_left
|
||||
size:TextSize
|
||||
size:text_size
|
||||
color:gx.rgb(0, 0, 0)
|
||||
}
|
||||
over_cfg = gx.TextCfg{
|
||||
align:gx.align_left
|
||||
size:TextSize
|
||||
size:text_size
|
||||
color:gx.White
|
||||
}
|
||||
)
|
||||
@ -84,7 +84,7 @@ const (
|
||||
[1111, 9, 1111, 9],
|
||||
]
|
||||
// Each tetro has its unique color
|
||||
Colors = [
|
||||
colors = [
|
||||
gx.rgb(0, 0, 0), // unused ?
|
||||
gx.rgb(255, 242, 0), // yellow quad
|
||||
gx.rgb(174, 0, 255), // purple triple
|
||||
@ -96,8 +96,8 @@ const (
|
||||
gx.rgb(0, 170, 170), // unused ?
|
||||
]
|
||||
|
||||
BackgroundColor = gx.White
|
||||
UIColor = gx.Red
|
||||
background_color = gx.White
|
||||
ui_color = gx.red
|
||||
)
|
||||
|
||||
// TODO: type Tetro [tetro_size]struct{ x, y int }
|
||||
@ -145,8 +145,8 @@ fn main() {
|
||||
glfw.init_glfw()
|
||||
|
||||
gconfig := gg.Cfg {
|
||||
width: WinWidth
|
||||
height: WinHeight
|
||||
width: win_width
|
||||
height: win_height
|
||||
use_ortho: true // This is needed for 2D drawing
|
||||
create_window: true
|
||||
window_title: 'V Tetris'
|
||||
@ -154,8 +154,8 @@ fn main() {
|
||||
}
|
||||
|
||||
fconfig := gg.Cfg{
|
||||
width: WinWidth
|
||||
height: WinHeight
|
||||
width: win_width
|
||||
height: win_height
|
||||
use_ortho: true
|
||||
font_path: '../assets/fonts/RobotoMono-Regular.ttf'
|
||||
font_size: 18
|
||||
@ -170,10 +170,10 @@ fn main() {
|
||||
game.init_game()
|
||||
game.gg.window.onkeydown(key_down)
|
||||
go game.run() // Run the game loop in a new thread
|
||||
gg.clear(BackgroundColor)
|
||||
gg.clear(background_color)
|
||||
game.font_loaded = game.ft != 0
|
||||
for {
|
||||
gg.clear(BackgroundColor)
|
||||
gg.clear(background_color)
|
||||
game.draw_scene()
|
||||
game.gg.render()
|
||||
if game.gg.window.should_close() {
|
||||
@ -189,15 +189,15 @@ fn (mut g Game) init_game() {
|
||||
g.generate_tetro()
|
||||
g.field = [] // TODO: g.field = [][]int
|
||||
// Generate the field, fill it with 0's, add -1's on each edge
|
||||
for _ in 0..FieldHeight + 2 {
|
||||
mut row := [0].repeat(FieldWidth + 2)
|
||||
for _ in 0..field_height + 2 {
|
||||
mut row := [0].repeat(field_width + 2)
|
||||
row[0] = - 1
|
||||
row[FieldWidth + 1] = - 1
|
||||
row[field_width + 1] = - 1
|
||||
g.field << row
|
||||
}
|
||||
mut first_row := g.field[0]
|
||||
mut last_row := g.field[FieldHeight + 1]
|
||||
for j in 0..FieldWidth + 2 {
|
||||
mut last_row := g.field[field_height + 1]
|
||||
for j in 0..field_width + 2 {
|
||||
first_row[j] = - 1
|
||||
last_row[j] = - 1
|
||||
}
|
||||
@ -222,7 +222,7 @@ fn (mut g Game) run() {
|
||||
g.delete_completed_lines()
|
||||
}
|
||||
glfw.post_empty_event() // force window redraw
|
||||
time.sleep_ms(TimerPeriod)
|
||||
time.sleep_ms(timer_period)
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,13 +267,13 @@ fn (mut g Game) move_right(dx int) bool {
|
||||
}
|
||||
|
||||
fn (mut g Game) delete_completed_lines() {
|
||||
for y := FieldHeight; y >= 1; y-- {
|
||||
for y := field_height; y >= 1; y-- {
|
||||
g.delete_completed_line(y)
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut g Game) delete_completed_line(y int) {
|
||||
for x := 1; x <= FieldWidth; x++ {
|
||||
for x := 1; x <= field_width; x++ {
|
||||
f := g.field[y]
|
||||
if f[x] == 0 {
|
||||
return
|
||||
@ -282,7 +282,7 @@ fn (mut g Game) delete_completed_line(y int) {
|
||||
g.score += 10
|
||||
// Move everything down by 1 position
|
||||
for yy := y - 1; yy >= 1; yy-- {
|
||||
for x := 1; x <= FieldWidth; x++ {
|
||||
for x := 1; x <= field_width; x++ {
|
||||
mut a := g.field[yy + 1]
|
||||
b := g.field[yy]
|
||||
a[x] = b[x]
|
||||
@ -293,7 +293,7 @@ fn (mut g Game) delete_completed_line(y int) {
|
||||
// Place a new tetro on top
|
||||
fn (mut g Game) generate_tetro() {
|
||||
g.pos_y = 0
|
||||
g.pos_x = FieldWidth / 2 - tetro_size / 2
|
||||
g.pos_x = field_width / 2 - tetro_size / 2
|
||||
g.tetro_idx = rand.next(b_tetros.len)
|
||||
g.rotation_idx = 0
|
||||
g.get_tetro()
|
||||
@ -326,14 +326,14 @@ fn (g &Game) draw_tetro() {
|
||||
}
|
||||
|
||||
fn (g &Game) draw_block(i, j, color_idx int) {
|
||||
color := if g.state == .gameover { gx.Gray } else { Colors[color_idx] }
|
||||
g.gg.draw_rect((j - 1) * BlockSize, (i - 1) * BlockSize,
|
||||
BlockSize - 1, BlockSize - 1, color)
|
||||
color := if g.state == .gameover { gx.gray } else { colors[color_idx] }
|
||||
g.gg.draw_rect((j - 1) * block_size, (i - 1) * block_size,
|
||||
block_size - 1, block_size - 1, color)
|
||||
}
|
||||
|
||||
fn (g &Game) draw_field() {
|
||||
for i := 1; i < FieldHeight + 1; i++ {
|
||||
for j := 1; j < FieldWidth + 1; j++ {
|
||||
for i := 1; i < field_height + 1; i++ {
|
||||
for j := 1; j < field_width + 1; j++ {
|
||||
f := g.field[i]
|
||||
if f[j] > 0 {
|
||||
g.draw_block(i, j, f[j])
|
||||
@ -346,18 +346,18 @@ fn (mut g Game) draw_ui() {
|
||||
if g.font_loaded {
|
||||
g.ft.draw_text(1, 3, g.score.str(), text_cfg)
|
||||
if g.state == .gameover {
|
||||
g.gg.draw_rect(0, WinHeight / 2 - TextSize, WinWidth,
|
||||
5 * TextSize, UIColor)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 0 * TextSize, 'Game Over', over_cfg)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'Space to restart', over_cfg)
|
||||
g.gg.draw_rect(0, win_height / 2 - text_size, win_width,
|
||||
5 * text_size, ui_color)
|
||||
g.ft.draw_text(1, win_height / 2 + 0 * text_size, 'Game Over', over_cfg)
|
||||
g.ft.draw_text(1, win_height / 2 + 2 * text_size, 'Space to restart', over_cfg)
|
||||
} else if g.state == .paused {
|
||||
g.gg.draw_rect(0, WinHeight / 2 - TextSize, WinWidth,
|
||||
5 * TextSize, UIColor)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 0 * TextSize, 'Game Paused', text_cfg)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'SPACE to resume', text_cfg)
|
||||
g.gg.draw_rect(0, win_height / 2 - text_size, win_width,
|
||||
5 * text_size, ui_color)
|
||||
g.ft.draw_text(1, win_height / 2 + 0 * text_size, 'Game Paused', text_cfg)
|
||||
g.ft.draw_text(1, win_height / 2 + 2 * text_size, 'SPACE to resume', text_cfg)
|
||||
}
|
||||
}
|
||||
//g.gg.draw_rect(0, BlockSize, WinWidth, LimitThickness, UIColor)
|
||||
//g.gg.draw_rect(0, block_size, win_width, limit_thickness, ui_color)
|
||||
}
|
||||
|
||||
fn (mut g Game) draw_scene() {
|
||||
|
@ -2,13 +2,16 @@ import rand
|
||||
import time
|
||||
import os
|
||||
|
||||
const (HelpText = ' Usage:\t./VCasino\n
|
||||
Description:\n VCasino is a little game only made to learn V.\n')
|
||||
const (GDesc = ' The object of Roulette is to pick the number where the spinning ball will land on the wheel.
|
||||
const (
|
||||
help_text = ' Usage:\t./VCasino\n
|
||||
Description:\n VCasino is a little game only made to learn V.\n'
|
||||
g_desc = ' The object of Roulette is to pick the number where the spinning ball will land on the wheel.
|
||||
If your number is the good one, you\'ll get your bet x3.
|
||||
If your number is the same color as the ball one, you\'ll get your bet /2.
|
||||
Otherwise, you will lose your bet.\n')
|
||||
const (Odd = 'Red' Even = 'Black')
|
||||
Otherwise, you will lose your bet.\n'
|
||||
odd = 'red'
|
||||
even = 'black'
|
||||
)
|
||||
|
||||
struct Options {
|
||||
long_opt string
|
||||
@ -16,7 +19,7 @@ struct Options {
|
||||
}
|
||||
|
||||
fn display_help() {
|
||||
println(HelpText + GDesc)
|
||||
println(help_text + g_desc)
|
||||
}
|
||||
|
||||
fn option_parser() bool {
|
||||
@ -42,7 +45,7 @@ fn str_is_nbr(s string) bool {
|
||||
fn get_bet_nbr() int {
|
||||
mut bet_nbr := -1
|
||||
for bet_nbr < 0 || bet_nbr > 49 {
|
||||
println('Reminder: Odd numbers are red and even are black.')
|
||||
println('Reminder: odd numbers are red and even are black.')
|
||||
println('Type the number you want to bet on (between 0 and 49):')
|
||||
line := os.get_line().trim_space()
|
||||
if line.len < 1 {
|
||||
@ -93,9 +96,9 @@ fn run_wheel(bet_nbr int, _bet int) int {
|
||||
winning_nbr := rand.next(50)
|
||||
print('Roulette Wheel spinning... and stops on the number $winning_nbr which is a ')
|
||||
if winning_nbr % 2 == 1 {
|
||||
println(Odd)
|
||||
println(odd)
|
||||
} else {
|
||||
println(Even)
|
||||
println(even)
|
||||
}
|
||||
if winning_nbr == bet_nbr {
|
||||
bet *= 3
|
||||
@ -129,7 +132,7 @@ fn game_loop() {
|
||||
mut can_play := true
|
||||
mut money := 1000
|
||||
|
||||
println(GDesc)
|
||||
println(g_desc)
|
||||
println('You start the game with $money V.\n')
|
||||
for can_play {
|
||||
bet_nbr := get_bet_nbr()
|
||||
|
Reference in New Issue
Block a user