2023의 게시물 표시

[ChatGPT][SDL2][2D RPG 게임 개발] SDL2 라이브러리와 지도 데이터를 저장하는 배열을 사용하여 창을 만들고 2D 맵 지도를 렌더링하는 C 파일의 예제 샘플

 [ChatGPT][SDL2][2D RPG 게임 개발] SDL2 라이브러리와 지도 데이터를 저장하는 배열을 사용하여 창을 만들고 2D 맵 지도를 렌더링하는 C 파일의 예제 샘플 // Here is an example of a C file that creates a window and renders a 2D world map using the SDL2 library and an array to store the map data #include "rpg_map.h" const int MAP_WIDTH = 100; const int MAP_HEIGHT = 100; int rpg_map[MAP_WIDTH][MAP_HEIGHT]; int main(int argc, char *argv[]) {     SDL_Init(SDL_INIT_VIDEO);     SDL_Window *window = SDL_CreateWindow("RPG World Map", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0);     SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0);     SDL_Surface* tileset = IMG_Load("tileset.png");     SDL_Texture* tileset_texture = SDL_CreateTextureFromSurface(renderer, tileset);     load_map_data();     while (1) {         SDL_Event event;         while (SDL_PollEvent(&event)) {             if (event.type == SDL_QUIT) {                 goto end;             }         }         render_map(renderer, til

[ChatGPT][SFML][2D 게임 개발] Player 클래스 및 관련 메서드를 정의하는 player.hpp 파일의 예제 샘플

 [ChatGPT][SFML][2D 게임 개발] Player 클래스 및 관련 메서드를 정의하는 player.hpp 파일의 예제 샘플 // Here is an example of a player.hpp file that defines the Player class and its associated methods #ifndef PLAYER_HPP #define PLAYER_HPP #include <SFML/Graphics.hpp> class Player {     public:         Player();         void update(float deltaTime);         void render(sf::RenderWindow& window);     private:         float x;         float y;         float speed;         sf::Texture texture;         sf::Sprite sprite; }; #endif /* This is a simple example, you can expand it to fit your needs. It will create a player with its texture loaded, and it will move the player based on the arrow keys pressed, and render it on the window. It uses delta time for smooth movement, you can add more complex behavior like jumping or shooting, it depends on the game you are building. It uses a class structure to encapsulate the player attributes and methods. The difference between this and the previous example is the fil

[ChatGPT][SFML][2D 게임 개발] SFML(Simple and Fast Multimedia Library) 라이브러리를 사용하여 플레이어를 만들고 이미지를 표시하는 player.cpp 파일의 예제 샘플

 [ChatGPT][SFML][2D 게임 개발] SFML(Simple and Fast Multimedia Library) 라이브러리를 사용하여 플레이어를 만들고 이미지를 표시하는 player.cpp 파일의 예제 샘플 // Here is an example of a player.cpp file that uses the Simple and Fast Multimedia Library (SFML) library to create a player and display an image of it #include "player.hpp" Player::Player(){     if (!texture.loadFromFile("player.png")) {         std::cout << "Error loading player texture\n";     }     sprite.setTexture(texture);     x = 0;     y = 0;     speed = 200; } void Player::update(float deltaTime) {     // handle player input and update player position     if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {         x -= speed * deltaTime;     }     if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {         x += speed * deltaTime;     }     if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {         y -= speed * deltaTime;     }     if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {         y += speed * deltaTime;     }    

[ChatGPT][SDL2][2D 게임 개발] EnemyAI 구조 및 관련 기능을 정의하는 enemy_ai.h 파일의 예제 샘플

 [ChatGPT][SDL2][2D 게임 개발] EnemyAI 구조 및 관련 기능을 정의하는 enemy_ai.h 파일의 예제 샘플 // Here is an example of an enemy_ai.h file that defines the EnemyAI struct and its associated functions #ifndef ENEMY_AI_H #define ENEMY_AI_H #include "enemy.h" #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 typedef struct {     int direction;     int speed; } EnemyAI; void initEnemyAI(EnemyAI* enemy_ai); void updateEnemyAI(EnemyAI* enemy_ai, Enemy* enemy); #endif /* This is a simple example, you can expand it to fit your needs. It moves the enemy randomly around the screen, when the enemy hit the border of the screen it will change the direction randomly. You can add more complex behavior like following the player, or attacking the player, or even spawning other enemies, it depends on the game you are building. It uses a struct structure to encapsulate the AI [번역] 이것은 간단한 예이므로 필요에 맞게 확장할 수 있습니다. 그것은 화면 주위에 적을 무작위로 이동하고, 적이 화면의 경계에 부딪히면 무작위로 방향을 바꿀 것입니다. 플레이어를 따르거나, 플레이어를 공격하거나, 심지어 다른 적을 생성하는 것과 같은

[ChatGPT][SDL2][2D 게임 개발] SDL(Simple DirectMedia Layer) 라이브러리를 사용하여 적 AI를 생성하고 적의 움직임을 제어하는 ​​enemy_ai.c 파일의 예제 샘플

 [ChatGPT][SDL2][2D 게임 개발] SDL(Simple DirectMedia Layer) 라이브러리를 사용하여 적 AI를 생성하고 적의 움직임을 제어하는 ​​enemy_ai.c 파일의 예제 샘플 // Here is an example of an enemy_ai.c file that uses the Simple DirectMedia Layer (SDL) library to create an enemy AI and control the movement of the enemy #include "enemy_ai.h" #include <stdlib.h> void initEnemyAI(EnemyAI* enemy_ai) {     enemy_ai->direction = rand() % 4;     enemy_ai->speed = 2; } void updateEnemyAI(EnemyAI* enemy_ai, Enemy* enemy) {     switch (enemy_ai->direction) {         case 0: // move up             enemy->y -= enemy_ai->speed;             break;         case 1: // move down             enemy->y += enemy_ai->speed;             break;         case 2: // move left             enemy->x -= enemy_ai->speed;             break;         case 3: // move right             enemy->x += enemy_ai->speed;             break;     }     if (enemy->x < 0 || enemy->x > SCREEN_WIDTH || enemy->y < 0 |

[ChatGPT][SDL2][2D 게임 개발] SDL(Simple DirectMedia Layer) 라이브러리를 사용하여 창을 만들고 플레이어 이미지를 표시하는 player.c 파일의 예제 샘플

 [ChatGPT][SDL2][2D 게임 개발] SDL(Simple DirectMedia Layer) 라이브러리를 사용하여 창을 만들고 플레이어 이미지를 표시하는 player.c 파일의 예제 샘플 // Here is an example of a player.c file that uses the Simple DirectMedia Layer (SDL) library to create a window and display an image of a player #include "player.h" #include <SDL2/SDL.h> void initPlayer(Player* player) {     player->x = 0;     player->y = 0;     player->texture = NULL; } int loadPlayerMedia(Player* player, SDL_Renderer* renderer) {     int success = 1;     SDL_Surface* surface = SDL_LoadBMP("player.bmp");     if(surface == NULL) {         printf("Unable to load image %s! SDL Error: %s\n", "player.bmp", SDL_GetError());         success = 0;     } else {         player->texture = SDL_CreateTextureFromSurface(renderer, surface);         if(player->texture == NULL) {             printf("Unable to create texture from %s! SDL Error: %s\n", "player.bmp", SDL_GetError());             succ

[ChatGPT][SFML][커스텀 2D 게임 엔진 개발] C++에서 자체 SFML 게임 엔진에 SFML을 사용하는 기본 게임 루프의 예제 샘플

 [ChatGPT][SFML][커스텀 2D 게임 엔진 개발] C++에서 자체 SFML 게임 엔진에 SFML을 사용하는 기본 게임 루프의 예제 샘플 // Here is an example of a basic game loop using SFML for your own SFML Game engine in C++ #include <SFML/Graphics.hpp> #include "engine.hpp" int main() {     // Initialize the engine     if (!Engine::init()) {         std::cout << "Error initializing engine" << std::endl;         return 1;     }     // Main loop flag     bool quit = false;     // Event handler     sf::Event event;     // While application is running     while (!quit) {         // Handle events on queue         while (Engine::getWindow().pollEvent(event)) {             // User requests quit             if (event.type == sf::Event::Closed) {                 quit = true;             }             // Pass event to engine             Engine::handleEvent(event);         }         // Update the engine         Engine::update();         // Render the engine         Engine::render();     }     // Clean up the

[ChatGPT][SDL2][커스텀 2D 게임 엔진 개발] C에서 자체 SDL기반 게임 엔진에 SDL2를 사용하는 기본 게임 루프의 예제 샘플

 [ChatGPT][SDL2][커스텀 2D 게임 엔진 개발] C에서 자체 SDL기반 게임 엔진에 SDL2를 사용하는 기본 게임 루프의 예제 샘플 // Here is an example of a basic game loop using SDL2 for your own SDL Game engine in C #include <SDL.h> #include "engine.h" int main(int argc, char* argv[]) {     // Initialize the engine     if (!engine_init()) {         printf("Error initializing engine: %s\n", SDL_GetError());         return 1;     }     // Main loop flag     int quit = 0;     // Event handler     SDL_Event e;     // While application is running     while (!quit) {         // Handle events on queue         while (SDL_PollEvent(&e) != 0) {             // User requests quit             if (e.type == SDL_QUIT) {                 quit = 1;             }             // Pass event to engine             engine_handle_event(&e);         }         // Update the engine         engine_update();         // Render the engine         engine_render();     }     // Clean up the engine     engine_cleanup();     return 0

[ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML기반 커스텀 2D 게임 엔진용 engine.hpp 파일의 예제 샘플

 [ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML기반 커스텀 2D 게임 엔진용 engine.hpp 파일의 예제 샘플 // Here is an example of an engine.hpp file for an SFML game engine #ifndef ENGINE_HPP #define ENGINE_HPP #include <SFML/Graphics.hpp> class Engine { public:     // Initialize the engine     static bool init();     // Update the engine     static void update();     // Render the engine     static void render();     // Clean up the engine     static void cleanup();     // Get the main window     static sf::RenderWindow& getWindow(); private:     // The main window     static sf::RenderWindow m_window; }; #endif /* This header file declares a class Engine that contains static member functions for initializing, updating, rendering, and cleaning up the game engine, as well as a static member function that returns a reference to the main window. Keep in mind that,  These examples are just a simple example and there are many ways to organize and optimize a game engine depending on the needs of the specific

[ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML기반 커스텀 2D 게임 엔진용 main.cpp 파일의 예제 샘플

 [ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML기반 커스텀 2D 게임 엔진용 main.cpp 파일의 예제 샘플 // Here is an example of a main.cpp file for an SFML game engine #include <SFML/Graphics.hpp> #include "engine.hpp" int main() {     // Initialize the engine     if (!Engine::init()) {         // Handle initialization error     }     // Main loop flag     bool quit = false;     // Event handler     sf::Event event;     // While application is running     while (!quit) {         // Handle events on queue         while (Engine::getWindow().pollEvent(event)) {             // User requests quit             if (event.type == sf::Event::Closed) {                 quit = true;             }         }         // Update the engine         Engine::update();         // Render the engine         Engine::render();     }     // Clean up the engine     Engine::cleanup();     return 0; } /* This example uses a separate engine.hpp file to initialize, update, and render the game engine.  Keep in mind that, These exa

[ChatGPT][SDL2][커스텀 2D 게임 엔진 개발] SDL2기반 커스텀 2D 게임 엔진용 engine.h 파일의 예제 샘플

 [ChatGPT][SDL2][커스텀 2D 게임 엔진 개발] SDL2기반 커스텀 2D 게임 엔진용 engine.h 파일의 예제 샘플 // Here is an example of an engine.h file for an SDL2 game engine #ifndef ENGINE_H #define ENGINE_H // Initialize the engine bool engine_init(); // Update the engine void engine_update(); // Render the engine void engine_render(); // Clean up the engine void engine_cleanup(); #endif /* This header file declares function prototypes for initializing, updating, rendering, and cleaning up the game engine. */

[ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML 기반 커스텀 2D게임 엔진용 스프라이트 편집기 생성 예제 코드 샘플

 [ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML 기반 커스텀 2D게임 엔진용 스프라이트 편집기 생성 예제 코드 샘플 /* Here's an example of how you could move the sprite using the arrow keys */ #include <SFML/Graphics.hpp> int main() {     sf::RenderWindow window(sf::VideoMode(800, 600), "Sprite Editor");     sf::Texture sprite_texture;     if (!sprite_texture.loadFromFile("sprite.png")) {         return -1;     }     sf::Sprite sprite(sprite_texture);     float speed = 200.0f; // pixels per second     sf::Clock clock;     while (window.isOpen()) {         sf::Event event;         while (window.pollEvent(event)) {             if (event.type == sf::Event::Closed) {                 window.close();             }         }         // Get the elapsed time since the last frame         float elapsed = clock.restart().asSeconds();         // Move the sprite based on the arrow keys         if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {             sprite.move(-speed * elapsed, 0);         }      

[ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML 기반 커스텀 2D게임 엔진용 스프라이트 편집기 생성 예제 코드 샘플

 [ChatGPT][SFML][커스텀 2D 게임 엔진 개발] SFML 기반 커스텀 2D게임 엔진용 스프라이트 편집기 생성 예제 코드 샘플 /* Here's an example of how you could move the sprite using the arrow keys */ #include <SFML/Graphics.hpp> int main() {     sf::RenderWindow window(sf::VideoMode(800, 600), "Sprite Editor");     sf::Texture sprite_texture;     if (!sprite_texture.loadFromFile("sprite.png")) {         return -1;     }     sf::Sprite sprite(sprite_texture);     float speed = 200.0f; // pixels per second     sf::Clock clock;     while (window.isOpen()) {         sf::Event event;         while (window.pollEvent(event)) {             if (event.type == sf::Event::Closed) {                 window.close();             }         }         // Get the elapsed time since the last frame         float elapsed = clock.restart().asSeconds();         // Move the sprite based on the arrow keys         if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {             sprite.move(-speed * elapsed, 0);         }      

[ChatGPT][SDL2][커스텀 2D 게임 엔진 개발] SDL2 기반 커스텀 2D게임 엔진용 스프라이트 편집기 생성 예제 코드 샘플

 [ChatGPT][SDL2][커스텀 2D 게임 엔진 개발] SDL2 기반 커스텀 2D게임 엔진용 스프라이트 편집기 생성 예제 코드 샘플 // Here's an example of how you could move the sprite using keyboard input in SDL2 #include "SDL.h" #include <iostream> int main(int argc, char* argv[]) {     SDL_Init(SDL_INIT_VIDEO);     SDL_Window* window = SDL_CreateWindow("Sprite Editor",                                           SDL_WINDOWPOS_UNDEFINED,                                           SDL_WINDOWPOS_UNDEFINED,                                           800, 600,                                           SDL_WINDOW_SHOWN);     SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0);     // Load the sprite image     SDL_Surface* sprite_surface = SDL_LoadBMP("sprite.bmp");     SDL_Texture* sprite_texture = SDL_CreateTextureFromSurface(renderer, sprite_surface);     SDL_FreeSurface(sprite_surface);     // Set the initial position of the sprite     SDL_Rect sprite_rect;     sprite_rect.x = 400;     sprite_rec

[ChatGPT][SFML][2D Game Dvelopment 2D 게임 개발] EnemyAI 클래스 및 관련 메서드를 정의하는 enemy_ai.hpp 파일의 예제 샘플

 [ChatGPT][SFML][2D 게임 개발] EnemyAI 클래스 및 관련 메서드를 정의하는 enemy_ai.hpp 파일의 예제 샘플 // Here is an example of an enemy_ai.hpp file that defines the EnemyAI class and its associated methods #ifndef ENEMY_AI_HPP #define ENEMY_AI_HPP #include "enemy.hpp" #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 class EnemyAI {     public:         EnemyAI();         void update(Enemy& enemy, float deltaTime);     private:         int direction;         float speed; }; #endif /* This is a simple example, you can expand it to fit your needs. It moves the enemy randomly around the screen, when the enemy hit the border of the screen it will change the direction randomly. You can add more complex behavior like following the player, or attacking the player, or even spawning other enemies, it depends on the game you are building. It uses a class structure to encapsulate the AI behavior and it receives an enemy object as parameter, so you can use this class for multiple enemies. The difference betw

[WebGL][P5.js][ WebGL Based 3D Game Development (Side Project) 웹 기반 3D게임 개발 연구 (사이드 프로젝트)] p5.js 3D Game Test Demo Scene (with Skybox) p5.js 3D 게임 데모 테스트

이미지
  2D Game / 3D WebGL Game Test Samples Source based in P5.js p5.js 3D Game Test Demo Scene (with Skybox) ========================================= 2년전에 걸쳐서 [P5.js][게임 개발 연구 (사이드 프로젝트)으로 구현해왔던 것인데 아직도 미흡한 것이 많다. 캐릭터의 부분적인 움직임(리깅 문제)인데 어떤 해외 유튜버가 프로세싱을 가지고 3D게임을 구현한 것을 보니 3D 캐릭터 머리, 팔, 다리 별로 따로따로 붙여서 구현한 것을 확인하였다. 아무래도 머리, 팔, 다리 별로 따로따로 붙여서 코딩을 구현해야할 것이 숙제. 솔직히 three.js 라이브러리를 통해서 3D 게임을 구현하는 것이 더 좋을 것이다. 개발 문서도 더 잘 정리가 잘 되어있고 구현하기가 더 편하다는 게 내 생각이다. 유튜브에 three.js 라이브러리 관련 튜토리얼 영상도 나오기 시작하고 말이다. Processing / P5.js도 WebGL기반이긴 하나 WebGL 통한 3D게임 구현 관련 자료가 현재 사실상 전무하다. 내 개인적으로도 코딩에 대한 부족함 때문에 착오 많이 겪고 있는 것이 사실이다. 궁금한 분들은 여기에 샘플 소스를 공개했으니  개인 깃허브 p5.js 3D 게임 데모  (오픈소스 라이센스:  GNU  GPL, 2.0버전) https://github.com/byungwoo733/2D_3D_Web_Game_Test_Sample_P5.js ============================== 데모 동영상 * (주의) 여기 예제나 글들은 게임개발에 도움이 되는 정보 보다는 개인 공부을 위한 것이니 옳은 방법이 아닐 수 있으니 참고바랍니다.

[Tistory 티스토리] Spread Wing G Studio 스프레드윙 G 스튜디오 (Dev-Blog Korean Version 한국어버전)

이미지
[Tistory 티스토리] Spread Wing G Studio  스프레드윙 G 스튜디오 (Dev-Blog Korean Version 한국어버전) https://spreadwing-gamestory.tistory.com/

[ChatGPT][SDL2 SDL2][SDL2 Development SDL2 개발] 2D 게임 캐릭터 스프라이트 SDL2 샘플 코드

2D 게임 캐릭터 스프라이트 SDL2 샘플 코드 #include <SDL2/SDL.h> int main() {     // Initialize SDL     SDL_Init(SDL_INIT_VIDEO);     // Create a window     SDL_Window* window = SDL_CreateWindow("Sprite Sheet Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, 0);     // Create a renderer     SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0);     // Load the sprite sheet     SDL_Surface* spriteSheet = SDL_LoadBMP("character.bmp");     SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, spriteSheet);     SDL_FreeSurface(spriteSheet);     // Set the starting animation frame     int frame = 0;     // Set the animation to the walking right animation     SDL_Rect srcRect = {frame * 64, 0, 64, 64}; // 64 is the width and height of each frame     // Main game loop     while (1) {         // Handle events         SDL_Event event;         if (SDL_PollEvent(&event)) {             if (event.type == SDL_QUIT) {                 break;             }

[ChatGPT][SDL2 Development SDL2 개발] 2D Sprite SDL2 Sample Code 2D 스프라이트 SDL2 샘플 코드

2D Sprite SDL2 Sample Code  2D 스프라이트 SDL2 샘플 코드 // Here is some sample code for creating a 2D sprite sheet in C using SDL # include <SDL2/SDL.h> int main () { // Initialize SDL SDL_Init(SDL_INIT_VIDEO); // Create a window SDL_Window* window = SDL_CreateWindow( "Sprite Sheet Example" , SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800 , 600 , 0 ); // Create a renderer SDL_Renderer* renderer = SDL_CreateRenderer(window, -1 , 0 ); // Load the sprite sheet SDL_Surface* spriteSheet = SDL_LoadBMP( "sprites.bmp" ); SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, spriteSheet); SDL_FreeSurface(spriteSheet); // Set the current frame to the first frame SDL_Rect srcRect = { 0 , 0 , 64 , 64 }; // Main game loop while ( 1 ) { // Handle events SDL_Event event; if (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { break ;