マガジンのカバー画像

c言語ゲームプログラムサンプル集

5
運営しているクリエイター

記事一覧

RPG

#include <stdio.h> #include <stdlib.h> #include <time.h>

int main() {
srand(time(NULL));

printf("Welcome to the RPG game!\n");

//ここにゲームのループを書きます
struct Player {
char nam

もっとみる

テニスゲーム

#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h>
#define WIDTH 50 #define HEIGHT 25

int ballX, ballY, ballDirX, ballDirY, paddleY;
char screen[WIDTH][HEIGHT];

void ini

もっとみる

横スクロールアクションゲーム

#include <SDL2/SDL.h>
#define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 #define PLAYER_WIDTH 50 #define PLAYER_HEIGHT 50

int main(int argc, char* argv[])
{
SDL_Window* window = NULL;
SDL_Re

もっとみる

テトリス

#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <time.h>
#define BOARD_WIDTH 10 #define BOARD_HEIGHT 20
#define PIECE_WIDTH 4 #define PIECE_HEIGHT 4

int board[BOARD_HEIGHT][BOARD

もっとみる

ブロック崩し

#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h>
#define WIDTH 50 #define HEIGHT 20

int paddleX = WIDTH / 2;
int ballX = WIDTH / 2;
int ballY = HEIGHT - 2;
int ballDirX

もっとみる