Break time-Unityではない別のツールで作るゲーム

今回はFK_CLIを使ったゲームを作っていきます。

このツールはVisualStudioを使って作る3dモデルの表示ツールととらえるといいと思います。
今回作ったゲームは時間内でどれだけ多くの数を倒せるかというゲームを作りました。
ゲームの中での敵の動きはfor文を使って20行で上下左右の動きを三角関数を使って設定しました。
ゲームの動画


本当は敵から球をよけることもしようかと考えました。しかし、当てるのがまず大変だったため実装を取りやめました。矢印キーで遊ぶ簡単なゲームなのでダウンロードして展開して遊んでみてください。

次はもっと面白いゲームを作る…。(決意)

ソースコードも載せておきます。

先端メディア学を取ることができたら次もゲームかなとは思いますが今季最後の挨拶とさせていただきます。



ソースコード↓(頭が割れる方は閲覧非推奨)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FK_CLI;

namespace Final
{
    class Program
    {
        static void Windowsetup(fk_AppWindow argwin)
        {
            argwin.Size = new fk_Dimension(1000, 1000);
            argwin.BGColor = new fk_Color(0.0, 0.0, 0.0);
        }
        static void ModelRedy(fk_Model argmodel, fk_AppWindow argwin, fk_Block argblock, fk_Material argmat)
        {
            argwin.Entry(argmodel);
            argmodel.Shape = argblock;
            argmodel.Material = argmat;
            argmodel.BMode = fk_BoundaryMode.AABB;
            argmodel.AdjustAABB();
        }
        static void Main(string[] args)
        {
            fk_Material.InitDefault();
            var window = new fk_AppWindow();
            Windowsetup(window);
            var sprite = new fk_SpriteModel();
            if (sprite.InitFont("rm1b.ttf") == false)
            {
                Console.WriteLine("Eerror");
            }
            sprite.SetPositionLT(0, 0);
            var sprite1= new fk_SpriteModel();
            if (sprite1.InitFont("rm1b.ttf") == false)
            {
                Console.WriteLine("Eerror");
            }
            sprite1.SetPositionLT(250, -350);
            window.Entry(sprite1);
            var sprite2 = new fk_SpriteModel();
            if (sprite2.InitFont("rm1b.ttf") == false)
            {
                Console.WriteLine("Eerror");
            }
            sprite2.SetPositionLT(0.0, 20.0);
            var sprite3 = new fk_SpriteModel();
            if (sprite3.InitFont("rm1b.ttf") == false)
            {
                Console.WriteLine("Eerror");
            }
            sprite3.SetPositionLT(0.0, -20.0);
            window.Entry(sprite3);
            var blockE = new fk_Block(1.0, 1.0, 1.0);
            var blockP = new fk_Block(2.0, 2.0, 2.0);
            var BulletS = new fk_Sphere(8,0.5);
            var Enemy = new fk_Model[100];
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    double x = (double)i * 5.0 - 22.5;
                    double y = (double)j * 5.0 - 10.0;
                    Enemy[10 * i + j] = new fk_Model();
                    Enemy[10 * i + j].Shape = blockE;
                    Enemy[10 * i + j].Material = fk_Material.Red;
                    Enemy[10 * i + j].BMode = fk_BoundaryMode.OBB;
                    Enemy[10 * i + j].AdjustOBB();
                    Enemy[10 * i + j].SmoothMode = true;
                    Enemy[10 * i + j].GlMoveTo(x, y, 0.0);
                    window.Entry(Enemy[10 * i + j]);
                }
            }
            var Bullet = new fk_Model();
            Bullet.Shape = BulletS;
            Bullet.Material = fk_Material.White;
            Bullet.BMode = fk_BoundaryMode.SPHERE;
            Bullet.AdjustSphere();
            Bullet.GlMoveTo(1000, 0, 0);
            var Player = new fk_Model();
            ModelRedy(Player,window,blockP,fk_Material.Green);
            Player.GlMoveTo(0.0, -30, 0.0);
            window.Entry(Player);
            Console.WriteLine("◆説明文◆");
            Console.WriteLine("緑のキューブ:プレーヤー/赤いキューブ:エネミー");
            Console.WriteLine("左右矢印キーでプレイヤーが移動");
            Console.WriteLine("上矢印キーで射撃");
            Console.WriteLine("エネミーに向かって玉を打ち当たったら100点(貫通弾)");
            var BGM = new GP_BGM("epoq.ogg");
            var SE = new GP_SE(2);
            SE.LoadData (0, "Shageki.wav");
            SE.LoadData (1, "Bakuhatu.wav");
            var time = 10000;
            double d = 0;
            int kill = 0;
            int score = 0;
            int sene = 1;
            int BulletPoint = 100;
            window.Open();
            BGM.Start();
            SE.Start();
            while (window.Update() == true)
            {
                if (sene == 1)
                {
                    string Message = "Plese look at Console./Push & Start SpaceKey.";
                    sprite.DrawText(Message, true);
                    sprite.SetPositionLT(-200.0, 0.0);
                    window.Entry(sprite);
                    if (window.GetKeyStatus(' ', fk_SwitchStatus.DOWN) == true)
                    {
                        sene = 2;
                        window.Remove(sprite);
                    }
                }
                if (sene == 2)
                {
                    time -= 1;
                    d += 1;
                    for (int j = 0; j < 10; j++)
                    {
                        Enemy[10 * j + 9].GlTranslate(Math.Cos(d * Math.PI / 360) * 0.10, 0, 0);
                        Enemy[10 * j + 8].GlTranslate(Math.Cos(d * Math.PI / 180) * 0.09, 0, 0);
                        Enemy[10 * j + 7].GlTranslate(Math.Cos(d * Math.PI / 345) * 0.10, 0, 0);
                        Enemy[10 * j + 6].GlTranslate(Math.Cos(d * Math.PI / 165) * 0.08, 0, 0);
                        Enemy[10 * j + 5].GlTranslate(Math.Cos(d * Math.PI / 330) * 0.09, 0, 0);
                        Enemy[10 * j + 4].GlTranslate(Math.Cos(d * Math.PI / 150) * 0.07, 0, 0);
                        Enemy[10 * j + 3].GlTranslate(Math.Cos(d * Math.PI / 315) * 0.08, 0, 0);
                        Enemy[10 * j + 2].GlTranslate(Math.Cos(d * Math.PI / 135) * 0.06, 0, 0);
                        Enemy[10 * j + 1].GlTranslate(Math.Cos(d * Math.PI / 300) * 0.07, 0, 0);
                        Enemy[10 * j + 0].GlTranslate(Math.Cos(d * Math.PI / 120) * 0.05, 0, 0);
                        Enemy[10 * 9 + j].GlTranslate(0, Math.Cos(d * Math.PI / 360) * 0.10, 0);
                        Enemy[10 * 8 + j].GlTranslate(0, Math.Cos(d * Math.PI / 180) * 0.09, 0);
                        Enemy[10 * 7 + j].GlTranslate(0, Math.Cos(d * Math.PI / 345) * 0.10, 0);
                        Enemy[10 * 6 + j].GlTranslate(0, Math.Cos(d * Math.PI / 165) * 0.08, 0);
                        Enemy[10 * 5 + j].GlTranslate(0, Math.Cos(d * Math.PI / 330) * 0.09, 0);
                        Enemy[10 * 4 + j].GlTranslate(0, Math.Cos(d * Math.PI / 150) * 0.07, 0);
                        Enemy[10 * 3 + j].GlTranslate(0, Math.Cos(d * Math.PI / 315) * 0.08, 0);
                        Enemy[10 * 2 + j].GlTranslate(0, Math.Cos(d * Math.PI / 135) * 0.06, 0);
                        Enemy[10 * 1 + j].GlTranslate(0, Math.Cos(d * Math.PI / 300) * 0.07, 0);
                        Enemy[10 * 0 + j].GlTranslate(0, Math.Cos(d * Math.PI / 120) * 0.05, 0);
                    }
                    time -= 1;
                    if (window.GetSpecialKeyStatus(fk_SpecialKey.LEFT, fk_SwitchStatus.PRESS) == true)
                    {
                        Player.GlTranslate(-0.2, 0.0, 0.0);
                    }
                    if (window.GetSpecialKeyStatus(fk_SpecialKey.RIGHT, fk_SwitchStatus.PRESS) == true)
                    {
                        Player.GlTranslate(0.2, 0.0, 0.0);
                    }
                    if (window.GetSpecialKeyStatus(fk_SpecialKey.UP, fk_SwitchStatus.DOWN) == true)
                    {
                        BulletPoint -= 1;
                        SE.StartSE(0);
                        Bullet.GlMoveTo(Player.Position.x, Player.Position.y + 3.0, 0.0);
                        window.Entry(Bullet);
                    }
                    Bullet.GlTranslate(0.0, 1.0, 0.0);
                    for (int e = 0; e < 100; e++)
                    {
                        if (Enemy[e].IsInter(Bullet) == true)
                        {
                            window.Remove(Enemy[e]);
                            SE.StartSE(1);
                            Enemy[e].BMode = fk_BoundaryMode.NONE;
                            score += 100;
                            kill += 1;
                        }
                    }
                    string Score = "Score:" + score.ToString();
                    sprite1.DrawText(Score, true);
                    sprite1.SetPositionLT(250.0, -350.0);
                    string bullet = "Bullet:" + BulletPoint.ToString();
                    sprite3.DrawText(bullet, true);
                    sprite3.SetPositionLT(100.0, -350.0);
                    if (time < 0)
                    {
                        string Message = "Time Over";
                        sprite.DrawText(Message, true);
                        sprite.SetPositionLT(0.0, 30.0);
                        window.Entry(sprite);
                        time = 0;
                        sene = 3;
                    }
                    if(BulletPoint<0)
                    {
                        string Message = "Bullet Empty";
                        sprite.DrawText(Message, true);
                        sprite.SetPositionLT(0.0, 30.0);
                        window.Entry(sprite);
                        time -= 0;
                        sene = 3;
                    }
                    if (kill > 99)
                    {
                        string Message = "All Complete";
                        sprite.DrawText(Message, true);
                        sprite.SetPositionLT(0.0, 30.0);
                        window.Entry(sprite);
                        time -= 0;
                        sene = 3;
                    }
                }
                if (sene == 3)
                {
                    int Rscore = time + score;
                    string timebounus = "YourTimebounus=" + time.ToString();
                    sprite2.DrawText(timebounus, true);
                    sprite2.SetPositionLT(0.0, 0.0);
                    window.Entry(sprite2);
                    string Fscore = "YourScore=" + Rscore.ToString();
                    sprite3.DrawText(Fscore, true);
                    sprite3.SetPositionLT(0.0, -30.0);
                    window.Entry(sprite3);
                }
            }
            BGM.StopStatus = true;
            SE.StopStatus = true;
        }
    }
}

コメント

このブログの人気の投稿

初投稿及びご挨拶

Unityのお話①/Unityを使った物理演算

サイクルモードに行ってきた!-その3