Init 2
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
src.bin
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								assets/ship.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/ship.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 574 B  | 
							
								
								
									
										20
									
								
								ols.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ols.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
			
		||||
{
 | 
			
		||||
    "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json",
 | 
			
		||||
    "enable_document_symbols": true,
 | 
			
		||||
    "enable_hover": true,
 | 
			
		||||
    "enable_snippets": true,
 | 
			
		||||
    "collections": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "core",
 | 
			
		||||
            "path": "/home/vlad/dev/builds/Odin/core"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "vendor",
 | 
			
		||||
            "path": "/home/vlad/dev/builds/Odin/vendor"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "src",
 | 
			
		||||
            "path": "src"
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								src/main.odin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								src/main.odin
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import rl "vendor:raylib"
 | 
			
		||||
import "core:math"
 | 
			
		||||
 | 
			
		||||
Object :: struct {
 | 
			
		||||
    position: [2]f32,
 | 
			
		||||
    velocity: [2]f32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Player :: struct {
 | 
			
		||||
    using object: Object,
 | 
			
		||||
    direction: f32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main :: proc() {
 | 
			
		||||
    rl.InitWindow(800, 600, "Torpedo Bots")
 | 
			
		||||
    rl.SetTargetFPS(60)
 | 
			
		||||
 | 
			
		||||
    ship := rl.LoadTexture("assets/ship.png")
 | 
			
		||||
    defer rl.UnloadTexture(ship)
 | 
			
		||||
    player := Player{}
 | 
			
		||||
 | 
			
		||||
    for !rl.WindowShouldClose() {
 | 
			
		||||
        delta := rl.GetFrameTime()
 | 
			
		||||
        if rl.IsKeyDown(rl.KeyboardKey.UP) {
 | 
			
		||||
            player.velocity = rl.Vector2MoveTowards(player.velocity, 300 * rl.Vector2Rotate({1,0}, math.to_radians(player.direction)), 700 * delta)
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        if rl.IsKeyDown(rl.KeyboardKey.LEFT) {
 | 
			
		||||
            player.direction -= 360 * delta
 | 
			
		||||
        }
 | 
			
		||||
        if rl.IsKeyDown(rl.KeyboardKey.RIGHT) {
 | 
			
		||||
            player.direction += 360 * delta
 | 
			
		||||
        }
 | 
			
		||||
        player.position += player.velocity * delta
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        using rl 
 | 
			
		||||
        {
 | 
			
		||||
            BeginDrawing()
 | 
			
		||||
            ClearBackground(RAYWHITE)
 | 
			
		||||
 | 
			
		||||
            DrawTexturePro(ship, {0, 0, 32, 32}, {player.position.x, player.position.y, 32, 32}, {16, 16}, player.direction + 90, WHITE)
 | 
			
		||||
            EndDrawing()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user