したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | |

C言語

1AF:2013/05/02(木) 09:21:50
参考用アドレス

2名無しさん:2013/05/02(木) 12:00:30
>>1
ぷぎゃー

3名無しさん:2013/05/02(木) 12:01:34
>>2
オウフ

4名無しさん:2013/05/02(木) 12:02:45
テスト

5AF:2013/05/02(木) 12:06:22
C言語をきちんと勉強したい人はこっちみてね。
http://wisdom.sakura.ne.jp/programming/index.html

6AF:2013/05/02(木) 12:10:23
C言語の関数について

http://wisdom.sakura.ne.jp/programming/c/c26.html

7わくわくさん:2013/05/02(木) 12:22:51
ちょちょちょ、ちょっとテンションたかすぎじゃないかな?

8ゴロリ:2013/05/02(木) 12:24:14
わくわくさんわくわくしすぎだよ

9名無しさん:2013/05/02(木) 12:29:40
>>8
zipでくれ

10名無しさん:2013/05/02(木) 12:31:20
>>9
クレクレやめろ(`・ω・´)

11ゴロリ:2013/05/02(木) 12:32:07
僕を取り合ってけんかするのはやめてよ!(、_'' (o)_: ( [三] ) _(o)`_, :::)

12名無しさん:2013/05/02(木) 12:32:57
>>11
同意

13DIK7:2013/05/02(木) 12:35:06
C言語行方不明

14名無しさん:2013/05/02(木) 12:35:59
ボケると誰かさんが突っ込んでくれるスレはここですか?

15名無しさん:2013/05/02(木) 13:20:08
C言語

16AF:2013/05/02(木) 13:45:47
http://wisdom.sakura.ne.jp/programming/c/c34.html

17AF:2013/05/02(木) 14:30:48
chap4のmain.hの完成版ソース その1
--------------------------------------------------
#include <DxLib.h>
#include <Box2D/Box2D.h>
#ifdef _DEBUG
#pragma comment(lib, "Box2D_d.lib")
#endif
#ifndef _DEBUG
#pragma comment(lib, "Box2D.lib")
#endif
#include "_dxdebugdraw.h"

//定数
#define B2D_DEBUG_DRAW
const int VELOCITYITE = 6; //速度計算精度
const int POSITIONITE = 2; //位置計算精度
const float GRAVITY_Y = 10.0f; //重力加速度
const float WLDSC = 50.0f; //世界倍率
const float SCREENAREA = 300.0f;//スクリーン範囲

//画像読み込み用構造体
struct Images{
int back[2]; //背景画像
int logo[3]; //ロゴ(タイトル、オーバー、クリア)
int titleback;
int hero[6]; //主人公キャラクター
};
//音声読み込み用構造体
struct Sounds{
};
//ゲームステート
enum GameState{
GAME_TITLE, GAME_MAIN, GAME_OVER, GAME_CLEAR
};
//ゲームデータ記録用構造体
struct StageInfo{
int timerstart; //待機タイマーの開始時刻
int gamestarttime; //ゲームの開始時間
int gametime; //ゲーム開始からの経過ミリ秒
float mapsize_w, mapsize_h; //マップサイズ
int screen_x, screen_y; //表示原点(スクロール用)

b2Body *wall; //床壁
b2Body *hero; //主人公
bool isheroleft; //主人公の向き
bool isontheground; //乗っている?
};
//HEROステート(アニメーション表示に使う列挙体)
enum HeroState{
//立つ、走る、ジャンプ
HERO_STANDING, HERO_RUNNING, HERO_JUMP
};

18AF:2013/05/02(木) 14:31:41
chap4のmain.hの完成版ソース その2
--------------------------------------------------

//関数プロトタイプ宣言
void MyMain();
int LoadFiles();
void InitStage();
void GoGameTitle();
void DrawGameTitle();
void GoGameMain();
void DrawGameMain();
void GoGameClear();
void DrawGameClear();
void GoGameOver();
void DrawGameOver();
b2Body* CreateDynamicBall(float x, float y, float radius);
b2Body* CreateBox(float x, float y, float w, float h, bool dynamic);
void Collision();

//ユーティリティ関数
bool IsAKeyTrigger(int key);
bool IsBKeyTrigger(int key);
bool IsCKeyTrigger(int key);
void DeleteAllBody();
int VIWX(float v);
int VIWY(float v);
float PHS(float v);
bool IsOutScreen(float x, float y);

//グローバル変数のエクスターン宣言
extern int g_lasttime;
extern float g_frametime;
extern bool g_exitflag;
extern b2World g_world;
#ifdef B2D_DEBUG_DRAW
extern DxDebugDraw g_debugdraw;
#endif
extern int g_middlefont;
extern StageInfo g_stage;

19AF:2013/05/02(木) 14:32:38
chap4のmain.cppの完成版ソース その1
--------------------------------------------------
#include "main.h"

//グローバル変数
GameState g_gamestate = GAME_TITLE;

//box2d関連
b2Vec2 gravity(0.0f, GRAVITY_Y); //重力加速度
b2World g_world(gravity, true); //Box2DWorld

//ゲームデータ
Images g_images; //画像データ
Sounds g_sounds; //音声データ
StageInfo g_stage; //ステージデータ

//メインループ
void MyMain(){
//ゲーム開始からの時間を計る
g_stage.gametime = g_lasttime - g_stage.gamestarttime;
//b2bの時間を進める
g_world.Step(g_frametime, VELOCITYITE, POSITIONITE);
//各画面の描画
switch(g_gamestate){
case GAME_TITLE:
DrawGameTitle();
break;
case GAME_MAIN:
DrawGameMain();
break;
case GAME_CLEAR:
DrawGameClear();
break;
case GAME_OVER:
DrawGameOver();
break;
}
}

//ファイルの読み込み
int LoadFiles(){
//ファイル読み込み処理をここに書く
if( LoadDivGraph("media\\chara_hero_l.png",
6, 6, 1, 46, 96, g_images.hero) == -1)
{
return -1;
}

//読み込み成功
return 1;
}

20AF:2013/05/02(木) 14:33:37
chap4のmain.cppの完成版ソース その2
--------------------------------------------------


//タイトル画面描画
void GoGameTitle(){
g_gamestate = GAME_TITLE;
}
void DrawGameTitle(){
//テキスト表示
DrawStringToHandle(100, 340, "Zキーでゲームスタート",
0x666666, g_middlefont);
//キーをチェックして画面切り替え
int key = GetJoypadInputState( DX_INPUT_KEY_PAD1 );
if(IsAKeyTrigger(key)==true) GoGameMain();
}
//ゲーム本編描画
void GoGameMain(){
g_gamestate = GAME_MAIN;
InitStage(); //ステージデータの初期化
}
void DrawGameMain(){
//衝突チェック
g_stage.isontheground = false;
Collision();
HeroState hstate = HERO_STANDING;
int key = GetJoypadInputState( DX_INPUT_KEY_PAD1 );
//主人公の位置と移動ベクトル
b2Vec2 pos = g_stage.hero->GetPosition();
b2Vec2 vec = g_stage.hero->GetLinearVelocity();
float angle = g_stage.hero->GetAngle();
//キーチェック
if(g_stage.isontheground == true){
//左右移動
if(key & PAD_INPUT_LEFT) {
vec.x = -PHS(120.0f);
g_stage.hero->SetLinearVelocity(vec);
hstate = HERO_RUNNING;
g_stage.isheroleft = true;
}
if(key & PAD_INPUT_RIGHT) {
vec.x = PHS(120.0f);
g_stage.hero->SetLinearVelocity(vec);
hstate = HERO_RUNNING;
g_stage.isheroleft = false;
}
//ジャンプ
if(IsBKeyTrigger(key) == true){
vec.x = 0;
vec.y = -62.0f;
g_stage.hero->ApplyLinearImpulse(vec, pos);
hstate = HERO_JUMP;
g_stage.isontheground = false;
}
}
//ジャンプ姿勢へ
if(g_stage.isontheground == false) hstate = HERO_JUMP;
//キャラクター描画
int animpat = (g_lasttime / (1000 / 12)) % 4;
switch(hstate){
case HERO_STANDING:
DrawRotaGraph(VIWX(pos.x), VIWY(pos.y), 1, angle,
g_images.hero[0], TRUE, g_stage.isheroleft);
break;
case HERO_RUNNING:
DrawRotaGraph(VIWX(pos.x), VIWY(pos.y), 1, angle,
g_images.hero[1 + animpat], TRUE,
g_stage.isheroleft);
break;
case HERO_JUMP:
DrawRotaGraph(VIWX(pos.x), VIWY(pos.y), 1, angle,
g_images.hero[5], TRUE, g_stage.isheroleft);
break;
}
//転倒対策
if( fabs(angle) > 0.2f ){
g_stage.hero->SetAngularVelocity(-angle*2);
}
}
//衝突判定
void Collision(){
//接触確認ループ
for(b2Contact* c = g_world.GetContactList(); c!=NULL;
c = c->GetNext())
{
if(c->IsTouching() == false) continue;
//接触しているボディを取り出す
b2Body* b1 = c->GetFixtureA()->GetBody();
b2Body* b2 = c->GetFixtureB()->GetBody();
//主人公のチェック
b2Body* hb = NULL;
b2Body* ob = NULL;
if(b1 == g_stage.hero) {hb = b1; ob = b2;}
if(b2 == g_stage.hero) {hb = b2; ob = b1;}
if(hb != NULL){
//主人公の足下確認
g_stage.isontheground = true;
}
}
}

21AF:2013/05/02(木) 14:34:15
chap4のmain.cppの完成版ソース その3
--------------------------------------------------
//ステージ初期化
void InitStage(){
//ゲームデータ全体のゼロ初期化
ZeroMemory(&g_stage, sizeof(g_stage));
//全ボディ・ジョイント削除
DeleteAllBody();

//ボールを追加
b2Body* ball = CreateDynamicBall(PHS(300), PHS(0), PHS(40));
g_stage.wall = CreateBox(PHS(320), PHS(400),
PHS(200), PHS(20), false);
g_stage.hero = CreateBox(PHS(140), PHS(300),
PHS(23), PHS(48), true);

//ゲーム開始時刻の記録
g_stage.gamestarttime = g_lasttime;
}


//ゲームクリア画面描画
void GoGameClear(){
g_gamestate = GAME_CLEAR;
g_stage.timerstart = g_lasttime;
}
void DrawGameClear(){
//5秒経ったらタイトル画面へ
if(g_lasttime - g_stage.timerstart > 5000) GoGameTitle();
}
//ゲームオーバー画面描画
void GoGameOver(){
g_gamestate = GAME_OVER;
g_stage.timerstart = g_lasttime;
}
void DrawGameOver(){
//5秒経ったらタイトル画面へ
if(g_lasttime - g_stage.timerstart > 5000) GoGameTitle();
}

b2Body* CreateDynamicBall(float x, float y, float radius){
//ボディ定義
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody; //動的ボディ
bodyDef.position.Set(x, y);
//ボディ作成
b2Body* body = g_world.CreateBody(&bodyDef);
//シェイプ作成
b2CircleShape dynamicBall;
dynamicBall.m_radius = radius;
//フィクスチャ定義
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBall;
fixtureDef.density = 4.0f; //密度
fixtureDef.restitution = 0.7f; //反発力
body->CreateFixture(&fixtureDef);
return body;
}

b2Body* CreateBox(float x, float y, float w, float h, bool dynamic){
//ボディ定義
b2BodyDef bodyDef;
if(dynamic) bodyDef.type = b2_dynamicBody; //動的ボディ
else bodyDef.type = b2_staticBody; //静的ボディ
bodyDef.position.Set(x, y);
//bodyDef.angle = 0.1f;
//ボディ作成
b2Body* body = g_world.CreateBody(&bodyDef);
//シェイプ作成
b2PolygonShape staticBox;
staticBox.SetAsBox(w, h);
//フィクスチャ定義
b2FixtureDef fixtureDef;
fixtureDef.shape = &staticBox;
fixtureDef.density = 4.0f; //密度
fixtureDef.restitution = 0.2f; //反発力
fixtureDef.friction = 0.2f; //摩擦係数
body->CreateFixture(&fixtureDef);
return body;
}

22バーバリー 帽子:2013/11/29(金) 13:13:44
C言語 - 余裕入力 x 地獄出力 バーバリー 帽子 http://www.burberry123.com/

23モンクレール 店舗:2013/11/30(土) 11:49:25
C言語 - 余裕入力 x 地獄出力 モンクレール 店舗 http://www.pslcbi.com/moncler2014.html


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板