Ejemplo n.º 1
0
        public void LoadResource(Game game)
        {
            Player p1 = new Player();

            p1.Transformation.Position.X = 300;
            p1.Transformation.Position.Y = 300;
            SpriteComponent sprite = new SpriteComponent(p1.Transformation, 3);
            ThrustComponent thrust = new ThrustComponent(2);

            p1.AddComponent(thrust);
            p1.AddComponent(sprite);
            thrust.GenerateParticles(600);
            Texture texture = game.LoadTexture(@"C:\Source\escape-aliens\Resources\SpaceShipRed.png");

            SDL.SDL_Rect renderRect;
            SDL.SDL_Rect sourceRect;
            renderRect.x = 0;
            renderRect.y = 0;
            renderRect.w = 80;
            renderRect.h = 80;

            sourceRect.w = 167;
            sourceRect.h = 170;
            sourceRect.x = 0;
            sourceRect.y = 0;

            texture.RenderRectangle = renderRect;
            texture.SourceRectangle = sourceRect;
            sprite.AddAnimationFrame(texture);

            game.Input.KeyboardBindings.AddMapping(SDL.SDL_Scancode.SDL_SCANCODE_D, p1.RotateRight);
            game.Input.KeyboardBindings.AddMapping(SDL.SDL_Scancode.SDL_SCANCODE_A, p1.RotateLeft);
            game.Input.KeyboardBindings.AddMapping(SDL.SDL_Scancode.SDL_SCANCODE_W, p1.Forward);
            game.AddObject(p1);

            Polygon2D poly = new Polygon2D();

            poly.AddPoint(300, 300);
            poly.AddPoint(600, 400);
            poly.AddPoint(400, 500);
            Texture         polyText      = game.LoadTexture(@"C:\Source\escape-aliens\Resources\MapForeground.png");
            FilledPolygon2D filledPolygon = new FilledPolygon2D(poly, polyText);
            Asteroid        asteroid      = new Asteroid();

            asteroid.AddComponent(filledPolygon);
            game.AddObject(asteroid);
        }