package ray_hypno
import rl "vendor:raylib"
WIN_W :: 800
WIN_H :: 600
CX :: WIN_W/2
CY :: WIN_H/2
START_RAD :: f32(WIN_W*3.1415992)
STP :: f32(8.5)
randcolor :: proc() -> rl.Color{
return rl.Color{
u8(rl.GetRandomValue(0,255)),
u8(rl.GetRandomValue(0,255)),
u8(rl.GetRandomValue(0,255)),
255
}
}
main :: proc(){
using rl
InitWindow(WIN_W,WIN_H,"Raylib hypno")
SetTargetFPS(60)
ToggleFullscreen()
// define array for colors
cols:[dynamic]rl.Color
defer delete(cols)
// add color set to array
sz:=START_RAD
for{
append(&cols,BLACK)
sz-=STP
if sz<=6 do break
}
// Preparation
current_col:=BLACK
target_col:=randcolor()
lerpfac:f32=0.0
// main loop
for !WindowShouldClose(){
// cycle colors
if lerpfac<1.0{lerpfac+=0.03}
current_col=ColorLerp(current_col,target_col,lerpfac)
ordered_remove(&cols,0)
append(&cols,current_col)
if GetRandomValue(1,1000)>850{
target_col=randcolor()
lerpfac=0
}
radx:f32=START_RAD
yratio:f32=WIN_W/WIN_H
// draw
BeginDrawing()
ClearBackground(BLACK)
for c in cols{
DrawEllipse(CX,CY,radx,radx/yratio,c)
radx-=STP
}
EndDrawing()
}
// Done
CloseWindow()
}
Since helping with the previous example, Iâve been hooked on playing around with Raylib and Odin. I blame you These two packages go together like
and
Thought Iâd share something Iâve been doing. If you want to display at your native screen resolution without all your background windows changing size, try the following. Just ESC to exit the display.
package ray_hypno
import rl "vendor:raylib"
STP :: f32(8.5)
randcolor :: proc() -> rl.Color{
return rl.Color{
u8(rl.GetRandomValue(0,255)),
u8(rl.GetRandomValue(0,255)),
u8(rl.GetRandomValue(0,255)),
255
}
}
WindowConfig := rl.ConfigFlags{ .FULLSCREEN_MODE }
main :: proc(){
using rl
SetConfigFlags(WindowConfig)
InitWindow(0,0,"Raylib hypno")
render_size: [2]i32 = {GetRenderWidth(), GetRenderHeight()}
WIN_W := render_size.x
WIN_H := render_size.y
CX := WIN_W/2
CY := WIN_H/2
START_RAD := f32(WIN_W)*3.1415992
SetTargetFPS(60)
//ToggleFullscreen()
// define array for colors
cols:[dynamic]rl.Color
defer delete(cols)
// add color set to array
sz:=START_RAD
for{
append(&cols,BLACK)
sz-=STP
if sz<=6 do break
}
// Preparation
current_col:=BLACK
target_col:=randcolor()
lerpfac:f32=0.0
// main loop
for !WindowShouldClose(){
// cycle colors
if lerpfac<1.0{lerpfac+=0.03}
current_col=ColorLerp(current_col,target_col,lerpfac)
ordered_remove(&cols,0)
append(&cols,current_col)
if GetRandomValue(1,1000)>850{
target_col=randcolor()
lerpfac=0
}
radx:f32=START_RAD
yratio:=f32(WIN_W)/f32(WIN_H)
// draw
BeginDrawing()
ClearBackground(BLACK)
for c in cols{
DrawCircle(CX,CY,radx/yratio,c)
radx-=STP
}
EndDrawing()
}
// Done
CloseWindow()
}
Very nice! I also think Odin and Raylib are a great combination.
For now I am slowly getting the hang of Raylib, and putting together simple starter templates. Based of your idea I now have a full screen starter template:
package ray_fullscreen
import rl "vendor:raylib"
main :: proc(){
using rl
SetConfigFlags(ConfigFlags{.FULLSCREEN_MODE})
InitWindow(0,0,"Raylib full screen")
SW,SH :i32 = GetRenderWidth(),GetRenderHeight()
SetTargetFPS(10)
// main loop
for !WindowShouldClose(){
BeginDrawing()
ClearBackground(BLUE)
DrawText(TextFormat("Screen size %ix%i",SW,SH),10,10,40,YELLOW)
EndDrawing()
}
// Cleanup
CloseWindow()
}
Nice. For what games usually refer to as âWindowed Fullscreenâ which doesnât change your displayâs graphics mode, you can do another template called, say âray_windowed_fullscreenâ
SetConfigFlags(ConfigFlags{.WINDOW_UNDECORATED, .BORDERLESS_WINDOWED_MODE, .WINDOW_TOPMOST, .WINDOW_MAXIMIZED})
fyi, I found that using .WINDOW_TOPMOST prevents from ALT-TABing out of the window. This can be a problem if your program has issues and you need to end task. My mistake on the first recomendation. Iâd change it to the follow instead.
SetConfigFlags(ConfigFlags{.WINDOW_UNDECORATED, .BORDERLESS_WINDOWED_MODE, .WINDOW_MAXIMIZED})
Thanks, and its a good catch to be aware of. I have updated my âborderless windowâ template with a comment regarding the impact of using .WINDOW_TOPMOST