INdT Mobile Labs - Sparta

32
# indtmobilelabs

Transcript of INdT Mobile Labs - Sparta

Page 1: INdT Mobile Labs - Sparta

# i n d t m o b i l e l a b s

Page 2: INdT Mobile Labs - Sparta

UTILIZANDO SPARTA PARA DESENVOLVIMENTO DE JOGOS

Page 3: INdT Mobile Labs - Sparta

ROTEIRO• Introdução ao desenvolvimento de jogos• Como funciona o XNA• Problemas no desenvolvimento• O que é o Sparta• Vantagens em usar Sparta• Arquitetura• Demos

Page 4: INdT Mobile Labs - Sparta

Introdução a jogos, sobre o XNA

DESENVOLVIMENTO DE JOGOS

Page 5: INdT Mobile Labs - Sparta

INTRODUÇÃOJogos são sistemas de tempo real pois precisam de resposta rápida e precisa

Não são 100% baseados em eventos, o jogo tem um loop que controla tudo

Page 6: INdT Mobile Labs - Sparta

GAME LOOP

while (!endGame){ input processamento do jogo output}

Page 7: INdT Mobile Labs - Sparta

GAME LOOP while (!endGame){ if (Keyboard.Jump.Pressed) { Player.Y -= 20 }

if (Player.Y == Moeda.Y) { Player.Pontos += 10 Moeda.Delete() }

Draw(Player, Player.X, Player.Y) Draw(Moeda, Moeda.X, Moeda.Y)}

Page 8: INdT Mobile Labs - Sparta

XNAÉ a solução disponível no Windows Phone para desenvolvimento de jogos

Silverlight = AppsXNA = Jogos

XNA + Silverlight perde um pouco de desempenho

Page 9: INdT Mobile Labs - Sparta

Memória, tombstoning, sprites, input e câmera

PARTICULARIDADES

Page 10: INdT Mobile Labs - Sparta

TOMBSTONINGTombstoning deve ser uma preocupação do programador quando desenvolver para Windows Phone

Não é uma obrigação do jogo ter tombstoning

:(

Page 11: INdT Mobile Labs - Sparta

CÂMERA E INPUTSeguir o jogador ou outro objeto

Facilidade em fazer transformações como zoom e scale

Cortar os objetos que estão fora da área desenhável

Page 12: INdT Mobile Labs - Sparta

CÂMERA E INPUTaTranslatedPoint.X = (float)(Math.Cos(theRotation) * (thePoint.X - theOrigin.X) - Math.Sin(theRotation) * (thePoint.Y - theOrigin.Y) + theOrigin.X);

float aNumerator = (theRectangleCorner.X * theAxis.X) + (theRectangleCorner.Y * theAxis.Y); float aDenominator = (theAxis.X * theAxis.X) + (theAxis.Y * theAxis.Y); float aDivisionResult = aNumerator / aDenominator; Vector2 aCornerProjected = new Vector2(aDivisionResult * theAxis.X, aDivisionResult * theAxis.Y);

float aScalar = (theAxis.X * aCornerProjected.X) + (theAxis.Y * aCornerProjected.Y);

Page 13: INdT Mobile Labs - Sparta

CONTROLE DE SPRITESÉ preciso uma classe para se fazer animações

Classe base para se adicionar em coleções

Classes derivadas de desenho que servem para outros propósitos

Page 14: INdT Mobile Labs - Sparta

MEMÓRIAPelas normas do Windows Phone Store aplicativos em celulares com 256mb não podem ultrapassar 90mb na RAM

Garbage Collector trava o jogo quando ativo

Tomar cuidado para não instanciar nada no loop pois enche a memória muito rápido

Sempre que possível reutilizar coleções ao invés de usar new e dispose

Page 15: INdT Mobile Labs - Sparta

O que é o Sparta, vantagens, arquitetura

THIS IS SPARTA!

Page 16: INdT Mobile Labs - Sparta
Page 17: INdT Mobile Labs - Sparta

O QUE É O SPARTAFramework para desenvolvimento de jogos 2D

Não é um engine

Precisávamos de algo rápido para prototipagem e desenvolvimento

Baseado em projetos open source como Flixel e Qt

Page 18: INdT Mobile Labs - Sparta

ARQUITETURASpartaGame

SpartaState SpartaState SpartaState

SpartaObjectSpartaSprite SpartaPropertyAnimation Sparta…

Page 19: INdT Mobile Labs - Sparta

ARQUITETURA

SpartaGame

SpartaState

SpartaSprite

UpdateDraw

UpdateDraw

UpdateDraw

Page 20: INdT Mobile Labs - Sparta

ARQUITETURA

MenuState LevelSelectState GameplayState

SpartaState

Page 21: INdT Mobile Labs - Sparta

ARQUITETURASpartaSprite SpartaTexture SpartaDrawable SpartaObject

SpartaButton SpartaTexture SpartaDrawable SpartaObject

SpartaCamera2D SpartaDrawable SpartaObject

Page 22: INdT Mobile Labs - Sparta

TEXTURE: XNA

Page 23: INdT Mobile Labs - Sparta

TEXTURE: XNAprivate Texture2D texture;

protected override void LoadContent(){ spriteBatch = new SpriteBatch(GraphicsDevice); texture = Content.Load<Texture2D>(“image");}

protected override void Draw(GameTime gameTime) { spriteBatch.Begin(); Vector2 pos = new Vector2(0, 0); spriteBatch.Draw(SpriteTexture, pos, Color.White); spriteBatch.End(); base.Draw(gameTime);}

Page 24: INdT Mobile Labs - Sparta

TEXTURE: SPARTA

private SpartaTexture texture;

texture = new SpartaTexture(“image”);

Add(texture);

Page 25: INdT Mobile Labs - Sparta

TRANSLAÇÃO: XNA

Page 26: INdT Mobile Labs - Sparta

TRANSLAÇÃO: XNAprivate Texture2D texture;

private Vector2 pos;private Vector2 posFinal;

private float velocidade;

protected override void LoadContent(){ spriteBatch = new SpriteBatch(GraphicsDevice); texture = Content.Load<Texture2D>(“image");

pos = Vector2.Zero;

velocidade = 10f;}

protected override void Draw(GameTime gameTime) { spriteBatch.Begin(); spriteBatch.Draw(SpriteTexture, pos, Color.White); spriteBatch.End(); base.Draw(gameTime);}

Protected override void Update(GameTime gameTime){ if (pos.x < posFinal.x) { pos.x += velocidade * (float)gameTime.ElapsedGameTime.TotalSeconds; }}

Page 27: INdT Mobile Labs - Sparta

TRANSLAÇÃO: SPARTA

private Texture2D texture;texture = new SpartaTexture(“image”);Add(texture);

SpartaPropertyAnimation animation = new SpartaPropertyAnimation(texture, "X", 0f, 100f, TimeSpan.FromMilliseconds(500), EasingCurve.EasingCurveType.OutCubic, null);

Add(animation);animation.Begin();

Page 28: INdT Mobile Labs - Sparta

FEATURES• Controle de telas• Transição entre telas• Engine física integrado• Sprites• PropertyAnimation• Classes pra UI• Som• Câmera• Tombstoning• Modo debug

Page 29: INdT Mobile Labs - Sparta

PLUS• Open Source e Free• Arquitetura simples• Desenvolvido pra ser extendido• Fácil usar para prototipagem• Desenvolvedores disponíveis• Usa XNA por baixo• Agora disponível em sabor morango

Page 30: INdT Mobile Labs - Sparta

ROADMAP• 3D• Multiplataforma (HTML5, C++/DirectX)• Construtor de Interface• Integrar engines de física de uma maneira flexível

Page 31: INdT Mobile Labs - Sparta

DEMO TIME!

Page 32: INdT Mobile Labs - Sparta

CONTATOSite do projetohttp://projects.developer.nokia.com/sparta

Grupo desenvolvimento de Windows Phonefacebook.com/groups/nokiadevwp/

[email protected]

[email protected]