LoginSignup
0
0

More than 5 years have passed since last update.

glutとC言語でシューティングゲーム0日目

Posted at

はじめに

れみです。
春休みで暇なのでプログラミングを始めたきっかけの弾幕シューティングゲームをglutとC言語で作ってみようと思う。5年以上前に龍神録プログラミングの館を参考に作ったことあってそれを思い出しながらやってみる。

自分の思い出を書き残しておこうかなと笑。
あとマークダウンの書き方練習。

環境構築

とりあえずwindowsなんだけどVisual Studioを使うと重くてちょっと...。というのも2012発売のdynabook T552を使ってるからですね。10か月くらい前に買ったやつ。中古で安かったんだもん。いつもはVirtual BoxでUbuntu18.04とか使ってたんだけどWSLも試してみたいなって思ってWSL上にUbuntu18.04をインストールしてそこで開発しようと思う。

環境

  • Windows 10
  • Ubuntu 18.04.2 LTS (Bionic Beaver)

WSLにUbuntuをインストールする方法は省略

エディタ

vim。
を使おうとしたらフォントがMSゴシック。調べたけどどうにもならないらしい。それはさすがに勘弁してほしかったからターミナルを変更。wslttyを使ってみることに。ここを参考に導入。

そのあとフォントにRicty Diminishedを導入。これで見た目がよくなった。

次にvimのカスタマイズ。
まあいつも研究室で使ってるようなかんじでいいや。
プラグインはとりあえずあったらいいやつ。え、twitter見れるのが最低限か?いいじゃん。

~/.vimrc
set number

set noswapfile
set title
set expandtab
set tabstop=2
set shiftwidth=2
set smartindent
set list
set clipboard=unnamed,autoselect
set belloff=all
set hlsearch
set termguicolors

"最後のカーソル位置復元
if has("autocmd")
  autocmd BufReadPost *
        \ if line("'\"") > 0 && line("'\"") <= line("$") |
        \ exe "normal! g'\"" |
        \ endif
endif

set nocompatible
filetype off

"let Vundle manage Vundle
"required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

"let Vundle manage Vundle
"reauired
Plugin 'gmarik/Vundle.vim'

"My Bundles here:
Plugin 'https://github.com/altercation/vim-colors-solarized.git'
Plugin 'https://github.com/Shougo/vimshell.git'
Plugin 'https://github.com/Shougo/vimproc'
Plugin 'https://github.com/Shougo/neocomplcache.vim'
Plugin 'https://github.com/Shougo/unite.vim'
Plugin 'https://github.com/vim-scripts/vim-auto-save'
Plugin 'https://github.com/twitvim/twitvim.git'

call vundle#end()
filetype plugin indent on

"色
syntax on
colorscheme molokai
set t_Co=256

"キーマッピング
nnoremap <silent> ,sh :VimShell<CR>

"Uniteの設定
noremap ,buf :Unite buffer<CR>
noremap ,file :Unite -buffer-name=file file<CR>
set number

"xml htmlのタグ補完
augroup MyXML
  autocmd!
  autocmd Filetype xml inoremap <buffer> </ </<C-x><C-o>
  autocmd Filetype html inoremap <buffer> </ </<C-x><C-o>
augroup END

"auto-save 設定
let g:auto_save = 1
let g:auto_save_in_insert_mode = 0
let g:auto_save_silent = 1

"twitvim 設定
let twitvim_force_ssl = 1
let twitvim_count = 40
noremap ,tw :PosttoTwitter<CR>
noremap ,tl :FriendsTwitter<CR>

"検索のハイライト消す
nnoremap <ESC><ESC> :noh<CR>

GLUT

たぶんこれで大丈夫。

$ sudo apt-get install libglu1-mesa-dev mesa-common-dev freeglut3-dev

空のウィンドウ作成

とりあえず空のウィンドウを出すところまでやってみる。環境構築だけですでに数時間経ってしまった...。これも全部MSゴシックのせい。

glutの記憶があいまいだからいろいろ調べながらかいてみた。

window.c
#include <GL/glut.h>

void display(){
}

int main(int argc, char *argv[]){
  //initialization
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE);
  glutInitWindowPosition(100, 100);
  glutInitWindowSize(640, 480);
  glutCreateWindow("test");
  glutDisplayFunc(display);


  //main loop
  glutMainLoop();

  return 0;
}

そしてコンパイル。

$ gcc window.c -o window -lglut -lGLU -lGL

さらに実行...しようとして気づいた。
Xサーバー忘れてた。

Xサーバー

定番のVcXsrvをインストール。

実行

$ ./window

うん、とりあえず黒い画面がでた。
明日からつらつらとつくっていこう。

参照

マークダウンの書き方メモを参考にしました。
https://qiita.com/hiroyuki_hon/items/f2a779bb295fd12646ab

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0