static void Main(string[] args) { //Planen är simpel, Ha en slags hub som finns i rpg-spel i starwars-tema där man kan interacta med saker som uppfyller alla kraven på A-nivå. //Detta då i star wars tema :) Raylib.InitWindow(800, 600, "Hello World"); float x = 100; float y = 400; var bruh = Raylib.LoadImage(@"C:\Users\axel.lilja2\Documents\PROG02\NovemberProjekt\novemberProjekt\bin\Debug\netcoreapp3.1\Character.png"); Texture2D texture = Raylib.LoadTextureFromImage(bruh); while (!Raylib.WindowShouldClose()) { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BLUE); Raylib.DrawTexture(texture, (int)x, (int)y, Color.WHITE); Raylib.EndDrawing(); } }
private static void Main( ) { Raylib.SetConfigFlags(ConfigFlag.FLAG_WINDOW_TRANSPARENT); Raylib.InitWindow(ViewWindow.Width, ViewWindow.Height, "Mogol"); Raylib.SetTargetFPS(int.MaxValue); float tickTimer = 0f; while (!Raylib.WindowShouldClose( )) { Update( ); if (Playing) { float tickTime = 1f / TPS; tickTimer += Raylib.GetFrameTime( ); if (tickTimer >= tickTime) { FixedUpdate( ); tickTimer -= tickTime; } } Raylib.BeginDrawing( ); Draw( ); Raylib.EndDrawing( ); } Raylib.CloseWindow( ); }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Snake"); Raylib.SetTargetFPS(60); GameObject snake = new Snake(); while (!Raylib.WindowShouldClose()) { snake.Update(); //LOGIK //GRAFIK Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BROWN); GameObject.DrawAll(); Raylib.EndDrawing(); } }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Bilder och grejer"); // Image - RAM-minnet, kan ändras på // Texture - Grafikkortet, kan ej ändras på, kan ritas ut Texture2D mike = Raylib.LoadTexture("mike.png"); float mikeX = 0; float mikeY = 0; string scene = "intro"; while (!Raylib.WindowShouldClose()) { // mikeX += 0.05f; // LOGIC: if (scene == "intro") { if (Raylib.IsKeyPressed(KeyboardKey.KEY_SPACE)) { scene = "game"; } } else if (scene == "game") { if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) { mikeX += 0.1f; } else if (Raylib.IsKeyDown(KeyboardKey.KEY_LEFT)) { mikeX -= 0.1f; } if (Raylib.IsKeyPressed(KeyboardKey.KEY_TAB)) { scene = "intro"; } } // DRAWING: Raylib.BeginDrawing(); if (scene == "intro") { Raylib.ClearBackground(Color.LIME); } else if (scene == "game") { Raylib.ClearBackground(Color.MAROON); Raylib.DrawTexture(mike, (int)mikeX, (int)mikeY, Color.WHITE); } Raylib.EndDrawing(); } }
public void Update() { drawScreen.Update(); Raylib.BeginDrawing(); Raylib.BeginTextureMode(renderTexture); Raylib.ClearBackground(Color.BLACK); Raylib.BeginMode3D(camera); ModelRenderer.RenderQueue(); Raylib.EndMode3D(); Raylib.EndTextureMode(); Raylib.ClearBackground(Color.BLACK); Raylib.DrawTexturePro( renderTexture.texture, new Rectangle(0, 0, renderTexture.texture.width, -renderTexture.texture.height), new Rectangle(0, 0, 640, 480), Vector2.Zero, 0, Color.RAYWHITE ); drawScreen.Render(); Raylib.EndDrawing(); Debug.Label("swap window"); }
static void Main(string[] args) { const int screenWidth = 1280; const int screenHeight = 720; Raylib.SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT | ConfigFlag.FLAG_VSYNC_HINT | ConfigFlag.FLAG_WINDOW_RESIZABLE); Raylib.InitWindow(screenWidth, screenHeight, "ImGui demo"); Raylib.SetTargetFPS(60); Random random = new Random(); _memoryEditorData = Enumerable.Range(0, 1024).Select(i => (byte)random.Next(255)).ToArray(); _controller.Load(screenWidth, screenHeight); // Main application loop while (!Raylib.WindowShouldClose()) { // Feed the input events to our ImGui controller, which passes them through to ImGui. _controller.Update(Raylib.GetFrameTime()); SubmitUI(); Raylib.BeginDrawing(); Raylib.ClearBackground(new Color((byte)(_clearColor.X * 255), (byte)(_clearColor.Y * 255), (byte)(_clearColor.Z * 255), (byte)255)); Raylib.DrawText("Hello, world!", 12, 12, 20, Color.BLACK); _controller.Draw(); Raylib.EndDrawing(); } _controller.Dispose(); Raylib.CloseWindow(); }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Game engine"); Raylib.SetTargetFPS(60); GameObject leftPaddle = new Paddle(10, 275, KeyboardKey.KEY_W, KeyboardKey.KEY_S); GameObject rightPaddle = new Paddle(770, 275, KeyboardKey.KEY_UP, KeyboardKey.KEY_DOWN); Ball ball = new Ball(); GameScreens screen = GameScreens.Start; while (!Raylib.WindowShouldClose()) { // LOGIK if (screen == GameScreens.Start) { if (Raylib.IsKeyPressed(KeyboardKey.KEY_ENTER)) { screen = GameScreens.Game; } } else if (screen == GameScreens.Game) { GameObject.UpdateAll(); } // ball.Update(); // GRAFIK Raylib.BeginDrawing(); if (screen == GameScreens.Start) { Raylib.ClearBackground(Color.GRAY); Raylib.DrawText("Press ENTER to start", 10, 10, 64, Color.BLACK); } else if (screen == GameScreens.Game) { Raylib.ClearBackground(Color.GOLD); GameObject.DrawAll(); } // if (Raylib.CheckCollisionRecs(ballRect, ball2Rect)) // { // Raylib.DrawText("JA", 10, 500, 64, Color.BLACK); // } // else // { // Raylib.DrawText("NEJ", 10, 500, 64, Color.BLACK); // } Raylib.EndDrawing(); } }
static void Main(string[] args) { // https://2dengine.com/?p=platformers Raylib.InitWindow(800, 600, "Platforming test"); Raylib.SetTargetFPS(60); new Ground(0, 500, 800, 20); new Ground(200, 400, 300, 20); Player p = new Player(); Level l = new Level("Level 1"); List <Level> levels = new List <Level>(); levels.Add(l); Level currentLevel = levels[0]; while (!Raylib.WindowShouldClose()) { p.Update(); Raylib.BeginDrawing(); Raylib.ClearBackground(Color.YELLOW); currentLevel.Draw(); GameObject.gameObjects.ForEach(x => x.Draw()); Raylib.EndDrawing(); } }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Testing"); Raylib.InitAudioDevice(); //New instances of player and tile Player newPlayer = new Player(10, 300, KeyboardKey.KEY_A, KeyboardKey.KEY_D, KeyboardKey.KEY_SPACE); Tile tile = new Tile(); Raylib.SetTargetFPS(60); Raylib.SetMasterVolume(0.3f); // Level level = new Level(); //main Loop while (!Raylib.WindowShouldClose()) { Raylib.BeginDrawing(); GameObject.UpdateAll(); Raylib.ClearBackground(Color.WHITE); GameObject.DrawAll(); Raylib.EndDrawing(); } }
void Draw() { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.DARKGRAY); player.Draw(); // darw all bullets for (int i = 0; i < bullets.Length; i++) { if (bullets[i] != null) { bullets[i].Draw(); } } // update all bullets for (int i = 0; i < asteroids.Length; i++) { if (asteroids[i] != null) { asteroids[i].Draw(); } } Raylib.EndDrawing(); }
public void Draw(RenderTexture2D target) { Raylib.BeginDrawing(); { Raylib.BeginTextureMode(target); Raylib.ClearBackground(new Color(36, 36, 36, 255)); Raylib.DrawTextEx( font, MoonVars.Name, new Vector2( Text.Center(MoonVars.RenderWidth, (int)textMeasure.X), MoonVars.RenderHeight / 4 ), fontSize, 1, new Color(196, 196, 196, 255) ); Raylib.DrawTextEx( instructFont, "Press Enter to Start", new Vector2( Text.Center(MoonVars.RenderWidth, (int)instructMeasure.X), MoonVars.RenderHeight / 4 * 3 ), instructFontSize, 1, Color.DARKBLUE ); stars.Draw(); Raylib.EndTextureMode(); } Raylib.EndDrawing(); }
static void Main(string[] args) { //Skapar mitt fönster där själva spelet visas, sätter även fps Raylib.InitWindow(800, 800, "Snake"); Raylib.SetTargetFPS(60); /*Skapar mina objekt, detta gör att de faktiskt exsiterar så att spelaren kan se de i mitt spel och * inte bara existerar i koden. Informationen om vad snake och äpple faktiskt ska göra hämtas sen från respektive klass. */ Snake s1 = new Snake(100, 200, KeyboardKey.KEY_W, KeyboardKey.KEY_S, KeyboardKey.KEY_D, KeyboardKey.KEY_A); Apple a1 = new Apple(); Text t1 = new Text(); //programmet körs så länge man inte tryckt på x-et som stänger rutan while (!Raylib.WindowShouldClose()) { /*Jag har en huvud klass med arv som kallas för GameObject, här samlas alla gameobjects som finns i spelet, * I denna del av koden så uppdateras spellogiken, med andra ord kollar den t.ex om spelaren trycker på någon knapp */ GameObject.UpdateAll(); t1.Update(); //Här ritas grafiken ut. Den kollar på vad som ska ritas ut i denna frame och ritar ut det på skrämen Raylib.BeginDrawing(); GameObject.DrawAll(); Text.Draw(); //Gör så att inte alla frames stannar kvar på skärmen, den rensar alltså så att nästa draw ska rita å ett "tomt canvas" Raylib.ClearBackground(Color.YELLOW); Raylib.EndDrawing(); } }
}//static void main // Second hand //Console.WriteLine("Welcome to your first day of many at the antiquary"); //Planen är att man ska kunna gå från rum till rum i en affär, och kunna plocka upp böcker som man kan köpa. //Sedan andra delen av spelet kommer man tillbaka till sin egen affär och ska sälja den till customers //Man får en rapport hur mycket man tjänar i slutet av dagen. Om man har kvar ett cursed item //får man problem under nästa dag. Om man säljer en cursed item till en customer som inte letar efter det //kommer man få en lawsuit, som man måste kunna betala av //Console.WriteLine(); //Console.ReadLine(); static void DrawHomescreen(Rectangle player, Rectangle background1, Rectangle background2, Rectangle background3, Rectangle background4, Rectangle background5, Rectangle roadVertical, Rectangle roadHorizontal, Rectangle aDoor, Rectangle sDoor) { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.WHITE); Raylib.DrawRectangleRec(roadVertical, Color.DARKGRAY); Raylib.DrawRectangleRec(roadHorizontal, Color.DARKGRAY); Raylib.DrawRectangleRec(background1, Color.GRAY); Raylib.DrawRectangleRec(background2, Color.GRAY); Raylib.DrawRectangleRec(background3, Color.GRAY); Raylib.DrawRectangleRec(background4, Color.GRAY); Raylib.DrawRectangleRec(background5, Color.GRAY); Raylib.DrawText("Welcome to a new day at the antiquary", 60, 80, 40, Color.BLACK); Raylib.DrawRectangle(200, 200, 300, 120, Color.RED); Raylib.DrawRectangleRec(sDoor, Color.BLACK); Raylib.DrawText("Second Hand Store", 215, 230, 25, Color.BLACK); Raylib.DrawRectangle(500, 410, 400, 200, Color.PURPLE); Raylib.DrawRectangleRec(aDoor, Color.BLACK); Raylib.DrawText("ANTIQUARY", 590, 450, 35, Color.BLACK); Raylib.DrawRectangleRec(player, Color.PURPLE); Raylib.EndDrawing(); }
// Drawing the game public void Draw() { Raylib.InitWindow(width, height, "Chess"); // generate chessboard and ui board = new(700, new Vector2Int(50, 50), this); ui = new(230, 700, new Vector2Int(760, 50), board); // defines menu menu = new(width, new Vector2Int(0, 0), this); // update function while (!Raylib.WindowShouldClose()) { // begins drawing Raylib.BeginDrawing(); // draw bg Raylib.ClearBackground(new Color(163, 163, 163, 255)); // Updates everything Update(); // ends drawing Raylib.EndDrawing(); } }
void Draw() { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BEIGE); //draw all bullets for (int i = 0; i < bullets.Length; i++) { if (bullets[i] != null) { bullets[i].Draw(); //explain this line } } player.Draw(); //draw all asteroids for (int i = 0; i < asteroids.Length; i++) { if (asteroids[i] != null) { asteroids[i].Draw(); } } Raylib.EndDrawing(); }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Goodbye world"); Texture2D ok = Raylib.LoadTexture("ok.png"); Color hotPink = new Color(255, 105, 180, 255); float xPos = 10; while (!Raylib.WindowShouldClose()) { // LOGIC if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) { xPos += 0.1f; } // DRAWING Raylib.BeginDrawing(); Raylib.ClearBackground(hotPink); //Raylib.DrawRectangle((int) xPos, 10, 50, 50, Color.WHITE); Raylib.DrawTexture(ok, (int)xPos, 10, Color.WHITE); Raylib.EndDrawing(); } }
static void DrawAntique(Rectangle player) { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BLACK); Raylib.DrawText("Antiquary", 60, 80, 40, Color.WHITE); Raylib.EndDrawing(); }
public static void Game() { cardsLeft.AddRange(CreateAllCards()); Raylib.SetTargetFPS(120); Raylib.InitWindow(1200, 800, "31"); bool gameActive = true; CreateButtons(); ResetGame(); while (gameActive) { Raylib.SetExitKey(0); Raylib.BeginDrawing(); Raylib.ClearBackground(Color.WHITE); RenderButtons(); if (Raylib.IsKeyPressed(KeyboardKey.KEY_R)) { ResetGame(); } else if (Raylib.IsKeyPressed(KeyboardKey.KEY_Q)) { gameActive = false; } Raylib.EndDrawing(); } Raylib.CloseWindow(); }
static void Main(string[] args) { Raylib.InitWindow(width, height, "Monke"); string fileName = @"Data.json"; System.Console.WriteLine(File.Exists(fileName)); string contents = File.ReadAllText(fileName); JsonConvert.DeserializeObject <SceneWrapper>(contents); SceneWrapper.Init(); string characterFile = @"Characters.json"; string characterContent = File.ReadAllText(characterFile); CharacterWrapper cw = JsonConvert.DeserializeObject <CharacterWrapper>(characterContent); int x = 0; SceneWrapper.scenes[x].Draw(); while (!Raylib.WindowShouldClose()) { Raylib.BeginDrawing(); SceneWrapper.DrawScene(); Raylib.EndDrawing(); } }
static void Main(string[] args) { // Initializes the handlers that need initializing ScreenHandler.Init(CONFIG_SCREEN); GameHandler.Init(); // To allow the esc button to be used as a pause button, // F12 have been set as the exit key. Raylib.SetExitKey(key: KeyboardKey.KEY_F12); while (!Raylib.WindowShouldClose()) { Raylib.BeginDrawing(); // Default color if it is not overbidden by a background in any stage. Raylib.ClearBackground(Color.BLANK); // GameHandler is a static class. StageHandler.Run(); GameHandler.Run(); Raylib.EndDrawing(); } Raylib.CloseWindow(); // When the game closes, it saves the config. // ScreenHandler.SaveCurrentConfiguration(); }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Test med TE19A"); float x = 0; while (!Raylib.WindowShouldClose()) { if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) { x += 0.1f; } Raylib.BeginDrawing(); //Color myNewColor = new Color(124, 255, 12, 255); Raylib.ClearBackground(Color.WHITE); Raylib.DrawRectangle((int)x, 0, 30, 30, Color.PINK); Raylib.EndDrawing(); } }
public void Draw() { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BLACK); Raylib.EndDrawing(); //s.DrawRectangle(); }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Bildtest"); Texture2D duckImage = Raylib.LoadTexture("duck.png"); float x = 20; while (!Raylib.WindowShouldClose()) { if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) { x += 0.1f; } Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BEIGE); //Raylib.DrawTexture(duckImage, 20, 20, Color.WHITE); Raylib.DrawTextureEx(duckImage, new Vector2(x, 20), 0f, 0.25f, Color.WHITE); Raylib.EndDrawing(); } }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Grafikdemo"); Color hotPink = new Color(255, 105, 180, 255); float x = 30; while (!Raylib.WindowShouldClose()) { if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) { x += 0.05f; } Raylib.BeginDrawing(); Raylib.ClearBackground(hotPink); Raylib.DrawRectangle((int)x, 10, 20, 20, Color.BLACK); Raylib.EndDrawing(); } }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Hello TE!"); Color myColor = new Color(0, 255, 128, 255); float x = 0; while (!Raylib.WindowShouldClose()) { if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) { x += 0.1f; } Raylib.BeginDrawing(); Raylib.ClearBackground(myColor); Raylib.DrawRectangle((int)x, 0, 20, 20, Color.PINK); Raylib.EndDrawing(); } }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Kollisioner"); Raylib.SetTargetFPS(60); Rectangle first = new Rectangle(10, 10, 50, 50); Rectangle second = new Rectangle(35, 35, 50, 50); Color semiTransparent = new Color(255, 0, 0, 128); while (!Raylib.WindowShouldClose()) { first.x += 0.5f; Raylib.BeginDrawing(); Raylib.ClearBackground(Color.SKYBLUE); Raylib.DrawRectangleRec(first, semiTransparent); Raylib.DrawRectangleRec(second, semiTransparent); if (Raylib.CheckCollisionRecs(first, second)) { Raylib.DrawText("YES", 100, 100, 64, Color.BLACK); } Raylib.EndDrawing(); } }
static void Main(string[] args) { Raylib.InitWindow(800, 600, "Kollisoner"); Rectangle playerRect = new Rectangle(0, 0, 100, 50); Rectangle enemyRect = new Rectangle(50, 60, 30, 30); Color red = new Color(255, 0, 0, 128); while (!Raylib.WindowShouldClose()) { //playerRect.x += 0.1f; playerRect.y += 0.01f; Raylib.BeginDrawing(); Raylib.ClearBackground(Color.LIGHTGRAY); Raylib.DrawRectangleRec(playerRect, red); Raylib.DrawRectangleRec(enemyRect, red); if (Raylib.CheckCollisionRecs(playerRect, enemyRect)) { Raylib.DrawText("Colliding!", 0, 550, 32, Color.BLACK); } Raylib.EndDrawing(); } }
static void Main(string[] args) { //pong game med Rocket League bilar + boll. Raylib.InitWindow(1000, 600, "Pong"); Raylib.SetTargetFPS(60); //Bil texturer Texture2D carTexture = Raylib.LoadTexture("car.png"); Texture2D carTextureL = Raylib.LoadTexture("carL.png"); GameObject leftPaddle = new Paddle(30, 275, KeyboardKey.KEY_W, KeyboardKey.KEY_S, carTextureL); GameObject rightPaddle = new Paddle(850, 275, KeyboardKey.KEY_UP, KeyboardKey.KEY_DOWN, carTexture); Ball ball = new Ball(); //start GameScreens screen = GameScreens.Start; while (!Raylib.WindowShouldClose()) { if (screen == GameScreens.Start) { if (Raylib.IsKeyPressed(KeyboardKey.KEY_ENTER)) { screen = GameScreens.Game; } } else if (screen == GameScreens.Game) { GameObject.UpdateAll(); } Raylib.BeginDrawing(); if (screen == GameScreens.Start) { Texture2D screenTexture; screenTexture = Raylib.LoadTexture("Sscreen.png"); Raylib.DrawTexture(screenTexture, (int)165, (int)1, Color.WHITE); Raylib.DrawText("Press ENTER to start", 173, 545, 58, Color.ORANGE); Raylib.ClearBackground(Color.BLACK); } else if (screen == GameScreens.Game) { Raylib.ClearBackground(Color.GREEN); GameObject.DrawAll(); } //ball.Update(); //ball.Draw(); Raylib.EndDrawing(); } }
//a method to create the button using raylib public void CreateButton(int posX, int posY, string text) { Raylib.BeginDrawing(); Raylib.DrawText(text, posX, posY, 10, Color.WHITE); Raylib.EndDrawing(); }
//Used to display objects and other info on the screen. public void Draw() { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.BLACK); Console.Clear(); _scenes[_currentSceneIndex].Draw(); Raylib.EndDrawing(); }