예제 #1
0
파일: Ship.cs 프로젝트: vjoensen/A5k
 override public void Draw()
 {
     SpriteDrawer.Draw(texture, pos, Vector2.One, Color.White, new Vector2(((float)texture.Width) / 2, ((float)texture.Height) / 2), rotation - (float)Math.PI / 2);
     if (framesSinceDamage < 30)
     {
         SpriteDrawer.DrawShield(texture, pos, Vector2.One * 1.1f, Color.Azure, new Vector2(((float)texture.Width) / 2, ((float)texture.Height) / 2), rotation - (float)Math.PI / 2, (30f - framesSinceDamage) / 40);
     }
 }
예제 #2
0
파일: PlayerShip.cs 프로젝트: vjoensen/A5k
 override public void Draw()
 {
     foreach (Weapon wep in weapons)
     {
         wep.Draw();
     }
     SpriteDrawer.Draw(texture, pos, Vector2.One, Color.White, new Vector2(((float)texture.Width) / 2, ((float)texture.Height) / 2), rotation - (float)Math.PI / 2);
 }
예제 #3
0
파일: Ship.cs 프로젝트: vjoensen/A5k
 public Ship(float spawnPosX, float spawnPosY, float spawnRotation, Texture2D shipTexture)
 {
     pos          = new Vector2(spawnPosX, spawnPosY);
     rotation     = spawnRotation;
     xVel         = 0;
     yVel         = 0;
     acceleration = 5;
     maxSpeed     = 20;
     texture      = shipTexture;
     radius       = Math.Max(shipTexture.Height, shipTexture.Width) / 2;
     faction      = Faction.Team2;
     weapon       = new Weapon(this, 0, 0, 0, new Texture2D(0, 0, 0), SpriteDrawer.LoadTexture("PNG\\Lasers\\laserRed01.png", true, false), 0, 0);
     weapon.setAttackSpeed(.2f);
 }
예제 #4
0
파일: MainWindow.cs 프로젝트: vjoensen/A5k
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            _time += e.Time;
            Title  = //$"{_title}: (Vsync: {VSync}) FPS: {1f / e.Time:0}, "+
                     "pos:" + view.getX() + "," + view.getY() + " mousePos: " + mousePos.X + "," + mousePos.Y + "shipPos:" + player.pos.X + "," + player.pos.Y;
            Color4 backColor;

            backColor.A = 1.0f;
            backColor.R = 0.1f;
            backColor.G = 0.1f;
            backColor.B = 0.3f;
            GL.ClearColor(backColor);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            GL.ClearStencil(0);


            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            //SpriteDrawer.Draw(texture, Vector2.Zero, Vector2.One, Color.Azure, new Vector2(((float)texture.Width)/2, ((float)texture.Height)/2));
            if (inventoryOpen)
            {
                inventory.Draw();
            }
            else
            {
                foreach (SpaceObject so in spaceObjects)
                {
                    so.Draw();
                }
                player.Draw();
                SpriteDrawer.DrawCursor(cursorTexture, mousePos, Vector2.One, Color.Azure, new Vector2(((float)cursorTexture.Width) / 2, ((float)cursorTexture.Height) / 2));
            }

            renderer.UpdateRenderTree();

            if (renderer.NeedsOffscreen())
            {
                renderer.RenderOffscreen();
            }

            renderer.Render();

            SwapBuffers();
        }
예제 #5
0
파일: PlayerShip.cs 프로젝트: vjoensen/A5k
        public PlayerShip(float spawnPosX, float spawnPosY, float spawnRotation, Texture2D shipTexture, Texture2D bulletTexture, View view)
        {
            faction            = Faction.Team1;
            pos                = new Vector2(spawnPosX, spawnPosY);
            rotation           = spawnRotation;
            xVel               = 0;
            yVel               = 0;
            acceleration       = 3;
            maxSpeed           = 10;
            texture            = shipTexture;
            this.bulletTexture = bulletTexture;
            this.view          = view;

            radius = Math.Max(shipTexture.Height, shipTexture.Width) / 2;

            weapons = new List <Weapon>();
            //weapons.Add(new Weapon(this, -20,15 , 0, SpriteDrawer.LoadTexture("PNG\\Parts\\gun09.png", false,false), SpriteDrawer.LoadTexture("PNG\\Lasers\\laserBlue01.png",true, false),2,20));
            //weapons.Add(new Shotgun(this, -20, 15, 0, SpriteDrawer.LoadTexture("PNG\\Parts\\gun04.png", false, false), SpriteDrawer.LoadTexture("PNG\\Lasers\\laserGreen13.png", true, false), 2, 20));
            //weapons.Add(new MissileLauncher(this, -20, 15, 0, SpriteDrawer.LoadTexture("PNG\\Parts\\gun07.png", false, false), SpriteDrawer.LoadTexture("PNG\\Sprites X2\\Missiles\\spaceMissiles_013.png", true, false), 2, 5));
            weapon1 = new MissileLauncher(this, -20, 15, 0, SpriteDrawer.LoadTexture("PNG\\Parts\\gun07.png", false, false), SpriteDrawer.LoadTexture("PNG\\Sprites X2\\Missiles\\spaceMissiles_013.png", true, false), 2, 5);
        }
예제 #6
0
파일: MainWindow.cs 프로젝트: vjoensen/A5k
        protected override void OnLoad(System.EventArgs e)
        {
            Noesis.GUI.Init();
            //EmbeddedXaml[] xamls = new EmbeddedXaml[]
            //{
            //        new EmbeddedXaml { filename = "Reflections.xaml", resource = "Reflections" }
            //};
            //Noesis.GUI.SetXamlProvider(new LocalXamlProvider("."));



            // Data loading
            Noesis.GUI.SetXamlProvider(new NoesisApp.LocalXamlProvider("."));
            //Noesis.Grid xaml = (Noesis.Grid)Noesis.GUI.LoadXaml("UI\\UItest0.xaml");
            xaml = new Noesis.Grid();
            Noesis.GUI.LoadComponent(xaml, "UI\\UItest03.xaml");
            //MyGrid xaml = new MyGrid();

            Noesis.StackPanel sp = (Noesis.StackPanel)xaml.FindName("BottomMenu");
            sp.DataContext = new ViewModel();



            Noesis.Button button = (Noesis.Button)xaml.FindName("button");

            button.Click += (object sender, Noesis.RoutedEventArgs args) =>
            {
                System.Console.WriteLine("Button was clicked");
            };


            // create view
            nView = Noesis.GUI.CreateView(xaml);

            nView.SetSize(this.Width, this.Height);
            // get OpenGL rendering device
            Noesis.RenderDevice device = new Noesis.RenderDeviceGL();

            // init renderer as OpenGL
            renderer = nView.Renderer;
            renderer.Init(device);


            nView.Update(0.001); // Ensures view is updated before first render call (avoids crash)


            CursorVisible = true;



            mousePos            = new Vector2(this.PointToClient(new Point(Mouse.GetCursorState().X, Mouse.GetCursorState().Y)).X, this.PointToClient(new Point(Mouse.GetCursorState().X, Mouse.GetCursorState().Y)).Y);
            Input.mousePosition = mousePos;
            //GL.Disable()
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);


            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);


            spritedrawer  = new SpriteDrawer(view);
            cursorTexture = SpriteDrawer.LoadTexture("PNG\\crosshair010.png", true, false);



            texture = SpriteDrawer.LoadTexture("PNG\\playerShip1_red.png", true, false);

            player  = new PlayerShip(0, 0, 0, texture, SpriteDrawer.LoadTexture("PNG\\Lasers\\laserBlue01.png", true, false), view);
            enemyAI = new AI(spaceObjects, player);
            Ship enemy1 = new Ship(200, 200, 0, SpriteDrawer.LoadTexture("PNG\\ufoBlue.png", true, false));

            player.setTarget(enemy1);


            enemyAI.takeControl(enemy1);
            spaceObjects.Add(enemy1);


            Closed += OnClosed;
        }