Initial commit, basic types
This commit is contained in:
		
							
								
								
									
										50
									
								
								game.odin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								game.odin
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import rl "vendor:raylib"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Pad :: struct {
 | 
				
			||||||
 | 
						position: Vec2, 
 | 
				
			||||||
 | 
						width: Vec2,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Ball :: struct {
 | 
				
			||||||
 | 
						position: Vec2,
 | 
				
			||||||
 | 
						velocity: Vec2,
 | 
				
			||||||
 | 
						radius: f32,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Brick :: struct {
 | 
				
			||||||
 | 
						position: Vec2,
 | 
				
			||||||
 | 
						size: Vec2,
 | 
				
			||||||
 | 
						color: rl.Color,
 | 
				
			||||||
 | 
						hits: u8,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Game :: struct {
 | 
				
			||||||
 | 
						using state: GameState,
 | 
				
			||||||
 | 
						lives: u8,
 | 
				
			||||||
 | 
						pad: Pad,
 | 
				
			||||||
 | 
						balls: [dynamic]Ball,
 | 
				
			||||||
 | 
						bricks: [dynamic]Brick,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					game_init :: proc() -> Game {
 | 
				
			||||||
 | 
						return Game{
 | 
				
			||||||
 | 
							update = game_update,
 | 
				
			||||||
 | 
							draw = game_draw,
 | 
				
			||||||
 | 
							lives = 3,
 | 
				
			||||||
 | 
							pad = Pad{
 | 
				
			||||||
 | 
								position = {f32(WINDOW_WIDTH / 2), f32(WINDOW_HEIGHT - 40)}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					game_update :: proc(delta: f32) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					game_draw :: proc() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										13
									
								
								main.odin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								main.odin
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import rl "vendor:raylib"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Vec2 :: [2]f32
 | 
				
			||||||
 | 
					Vec2i :: [2]i32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WINDOW_WIDTH : i32
 | 
				
			||||||
 | 
					WINDOW_HEIGHT : i32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					main :: proc() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										8
									
								
								menu.odin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								menu.odin
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import rl "vendor:raylib"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Menu :: struct {
 | 
				
			||||||
 | 
						using state: GameState,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										15
									
								
								state.odin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								state.odin
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GameState :: struct {
 | 
				
			||||||
 | 
						update: proc(f32),
 | 
				
			||||||
 | 
						draw: proc(),
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						variant: union{^Game, ^Menu}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					new_state :: proc($T: typeid) -> ^T {
 | 
				
			||||||
 | 
						state := new(T)
 | 
				
			||||||
 | 
						state.variant = state
 | 
				
			||||||
 | 
						return state
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user