・libgdxでゲーム作るんだ…。
・応用情報受けるんだ…。
いじょう。
分からなくて困ってます…
移動を追加して、全体的にそれっぽいコメント入れてみましたw
define.h
► スポイラーを表示
#pragma once
//----------------------------------------------------------------------------//
// 定数
//----------------------------------------------------------------------------//
#define SCREEN_X (600)
#define SCREEN_Y (400)
#define SCREEN_DEFAULT_POS_X (300)
#define SCREEN_DEFAULT_POS_Y (100)
#define CIRCLE_MAX (3)
//----------------------------------------------------------------------------//
// 型定義
//----------------------------------------------------------------------------//
typedef enum {
GREEN,
BLUE,
RED,
YELLOW,
AQUABLUE,
MAGENTA,
WHITE,
} E_color;
typedef struct {
double pos_x, pos_y;
int radius;
double angle, speed;
E_color color;
} circle_t;
► スポイラーを表示
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")
#include "wingxa.h"
#include "define.h"
#define _USE_MATH_DEFINES
#include
#include
//----------------------------------------------------------------------------//
// プロトタイプ
//----------------------------------------------------------------------------//
void BlendDraw(circle_t *cir);
bool HitCheck(int,int,circle_t *cir,circle_t *cir2);
void CircleDraw(circle_t *cir);
void CircleMove(circle_t *cir);
//----------------------------------------------------------------------------//
// メイン
//----------------------------------------------------------------------------//
void main(void)
{
// 位置x, 位置y, 半径, 角度, 速度, 色
circle_t circle[3] =
{
-0.5*100, 100*(1-sqrt(3.0)/4), 100, 90, 10, GREEN,
0.5*100, 100*(1-sqrt(3.0)/4), 100, 180, 15, BLUE,
0, 100*(1+sqrt(3.0)/4), 100, 270, 5, RED
};
gwinsize(SCREEN_X,SCREEN_Y); // 画面のサイズを指定
ginit(2);
gsetorg(SCREEN_DEFAULT_POS_X,SCREEN_DEFAULT_POS_Y); // スクリーン内の原点座標を指定
while(!keypress()){
CircleDraw(circle);
BlendDraw(circle);
CircleMove(circle);
swapbuffers();
}
}
/**
* 加法混色描画処理
* @param *cir 円データ
*/
void BlendDraw(circle_t *cir)
{
int ix, iy;
// 画面サイズ/スクリーン原点に合わせる(ix、iy)
for (iy=-SCREEN_DEFAULT_POS_Y; iypos_x)*(px-cir->pos_x) + (py-cir->pos_y)*(py-cir->pos_y) - (cir->radius*cir->radius) pos_x)*(px-cir2->pos_x) + (py-cir2->pos_y)*(py-cir2->pos_y) - (cir2->radius*cir2->radius) color){
case RED:
gcolor(255,0,0);
break;
case GREEN:
gcolor(0,255,0);
break;
case BLUE:
gcolor(0,0,255);
break;
}
gcirc((cir+num)->pos_x, (cir+num)->pos_y, (cir+num)->radius);
}
}
/**
* 円の移動処理
* @param *cir 円データ
*/
void CircleMove(circle_t *cir)
{
int num;
for(num=0; numpos_x += cos((cir+num)->angle) * (cir+num)->speed;
(cir+num)->pos_y += sin((cir+num)->angle) * (cir+num)->speed;
// 壁判定
if ( (cir+num)->pos_x > SCREEN_X-SCREEN_DEFAULT_POS_X - ((cir+num)->speed+(cir+num)->radius) ) (cir+num)->angle = (rand()%180+90) * (M_PI/180);// 右画面判定
if ( (cir+num)->pos_x speed+(cir+num)->radius) ) (cir+num)->angle = (rand()%180+270) * (M_PI/180);// 左画面判定
if ( (cir+num)->pos_y > SCREEN_Y-SCREEN_DEFAULT_POS_Y-((cir+num)->speed+(cir+num)->radius) ) (cir+num)->angle = (rand()%180+180) * (M_PI/180);// 上画面判定
if ( (cir+num)->pos_y speed+(cir+num)->radius) ) (cir+num)->angle = rand()%180 * (M_PI/180);// 下画面判定
}
}
実行結果
wingxa
基本は5年前ぐらいに受かったけど、この5年のブランク後に応用情報なんて受かるのか…?
受かる気がしない!(´・ω・`)ノシ