Fórum Sharpgames
 
 
  Forum  Criação de Jogo...  Gráficos 2D/3D  tutorial mappy e xna do luciano
Anterior Anterior
 
Próximo Próximo
Nova Entrada 30/11/2008 18:38
  lucianoJose
123 tópicos
Iniciante


Re: tutorial mappy e xna do luciano  
Modificado Por lucianoJose  em 30/11/2008 16:41:39)
 linuxboy escreveu

protected

{

 

override void LoadContent()// Create a new SpriteBatch, which can be used to draw textures.

 

 

 

 

 

 

 

 

myBase =

 

graphics.PreferredBackBufferWidth,

graphics.PreferredBackBufferHeight);

myBall =

 

graphics.PreferredBackBufferWidth,

graphics.PreferredBackBufferHeight);

graphics.PreferredBackBufferWidth = 800;

graphics.PreferredBackBufferHeight = 600;

graphics.ApplyChanges();

 

 

 

 

 

 

this.spriteBatch = new SpriteBatch(GraphicsDevice);this.Services.AddService(typeof(SpriteBatch), this.spriteBatch);this.mapLayer.LoadContent("mapa1.FMP", this.mappyLoader);this.mapLayer.TileStripTexture = this.Content.Load<Texture2D>("tilebloco");this.mapLayer.BuildSourceRectanglesTileStrip(3, 2, 5);new clsSprite(Content.Load<Texture2D>("base-arkanoide"),new Vector2(280f, 570f), new Vector2(64f, 64f),new clsSprite(Content.Load<Texture2D>("bolinha"),new Vector2(365f, 540f), new Vector2(64f, 64f),// Create a new SpriteBatch, which can be used to draw textures.

spriteBatch =

}

 

new SpriteBatch(GraphicsDevice);///

 

/// UnloadContent will be called once per game and is the place to unload

 

/// all content.

 

///


Begin must be called successfully before a Draw can be called.




linux melhora a formatação do teu código, e acho que o texto da tua indagação ficou bugada...

Tipo, para ficar com a formatação boa, eu copio o código do Visual Studio, dai colo no Word, depois eu copio todo o código que está no Word e colo no editor de texto aqui do sharpgames. Fazendo assim a formatação fica legal...

MCP, MCTS. Administrador do SharpGames. Game Developer(C++) at Manifesto Game Studio Meu Blog: lucianojosefj.spaces.live.com
 
Nova Entrada 30/11/2008 19:01
  linuxboy
20 tópicos
9th Level Poster


Re: tutorial mappy e xna do luciano  
desculpa luciano ve se agpora ficou bom !


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Audio;

using Microsoft.Xna.Framework.Content;

using Microsoft.Xna.Framework.GamerServices;

using Microsoft.Xna.Framework.Graphics;

using Microsoft.Xna.Framework.Input;

using Microsoft.Xna.Framework.Media;

using Microsoft.Xna.Framework.Net;

using Microsoft.Xna.Framework.Storage;

using LoaderMapFromMappy;

 

 

namespace arkanoidxna

{

/// <summary>

/// This is the main type for your game

/// </summary>

public class Game1 : Microsoft.Xna.Framework.Game

{

GraphicsDeviceManager graphics;

SpriteBatch spriteBatch;

clsSprite myBase; // sprite para a basse

clsSprite myBall; // sprite para a bolinha

clsSprite[] myBackground = new clsSprite[10]; //sprite para a imagem de fundo ou telas

 

 

private MappyLoader mappyLoader;

private MapLayer mapLayer;

 

 

 

public Game1()

{

graphics = new GraphicsDeviceManager(this);

Content.RootDirectory = "Content";

}

 

/// <summary>

/// Allows the game to perform any initialization it needs to before starting to run.

/// This is where it can query for any required services and load any non-graphic

/// related content. Calling base.Initialize will enumerate through any components

/// and initialize them as well.

/// </summary>

protected override void Initialize()

{

// TODO: Add your initialization logic here

 

this.mappyLoader = new MappyLoader();

this.mapLayer = new MapLayer(this);

 

base.Initialize();

}

 

/// <summary>

/// LoadContent will be called once per game and is the place to load

/// all of your content.

/// </summary>

protected override void LoadContent()

{

// Create a new SpriteBatch, which can be used to draw textures.

 

this.spriteBatch = new SpriteBatch(GraphicsDevice);

 

this.Services.AddService(typeof(SpriteBatch), this.spriteBatch);

 

this.mapLayer.LoadContent("mapa1.FMP", this.mappyLoader);

 

this.mapLayer.TileStripTexture = this.Content.Load<Texture2D>("tilebloco");

 

this.mapLayer.BuildSourceRectanglesTileStrip(3, 2, 5);

 

 

 

myBase = new clsSprite(Content.Load<Texture2D>("base-arkanoide"),

new Vector2(280f, 570f), new Vector2(64f, 64f),

graphics.PreferredBackBufferWidth,

graphics.PreferredBackBufferHeight);

 

myBall = new clsSprite(Content.Load<Texture2D>("bolinha"),

new Vector2(365f, 540f), new Vector2(64f, 64f),

graphics.PreferredBackBufferWidth,

graphics.PreferredBackBufferHeight);

 

graphics.PreferredBackBufferWidth = 800;

graphics.PreferredBackBufferHeight = 600;

graphics.ApplyChanges();

 

 

 

 

 

 

// Create a new SpriteBatch, which can be used to draw textures.

spriteBatch = new SpriteBatch(GraphicsDevice);

 

}

 

/// <summary>

/// UnloadContent will be called once per game and is the place to unload

/// all content.

/// </summary>

protected override void UnloadContent()

{

// TODO: Unload any non ContentManager content here

}

 

/// <summary>

/// Allows the game to run logic such as updating the world,

/// checking for collisions, gathering input, and playing audio.

/// </summary>

/// <param name="gameTime">Provides a snapshot of timing values.</param>

protected override void Update(GameTime gameTime)

{

// Allows the game to exit

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

this.Exit();

 

// TODO: Add your update logic here

 

base.Update(gameTime);

}

 

/// <summary>

/// This is called when the game should draw itself.

/// </summary>

/// <param name="gameTime">Provides a snapshot of timing values.</param>

protected override void Draw(GameTime gameTime)

{

 

 

// TODO: Add your drawing code here

 

this.graphics.GraphicsDevice.Clear(Color.Black);

 

this.spriteBatch.Begin();

this.mapLayer.Draw(gameTime);

this.spriteBatch.End();

spriteBatch.Draw(myBall.texture, myBall.position, Color.White);

spriteBatch.Draw(myBase.texture, myBase.position, Color.White);

base.Draw(gameTime);

 

 

 

 

 

}

}

 

class clsSprite

{

public Texture2D texture; // plano de fundo

public Vector2 position; // posição do desenho

public Vector2 size; // tamanho do desenho em pixels

public Vector2 screenSize; // tamanho da tela

public Vector2 velocity; // velocidade do movimento

 

 

// controle de velocidade do objeto

 

public void Move()

{

// if we'll move out of the screen, invert velocity

// checking right boundary

if (position.X + size.X + velocity.X > screenSize.X)

velocity.X = -velocity.X;

// checking bottom boundary

if (position.Y + size.Y + velocity.Y > screenSize.Y)

velocity.Y = -velocity.Y;

// checking left boundary

if (position.X + velocity.X < 0)

velocity.X = -velocity.X;

// checking bottom boundary

if (position.Y + velocity.Y < 0)

velocity.Y = -velocity.Y;

// since we adjusted the velocity, just add it to the current position

position += velocity;

}

 

public clsSprite(Texture2D newTexture, Vector2 newPosition, Vector2 newSize, int ScreenWidth, int ScreenHeight)

{

texture = newTexture;

position = newPosition;

size = newSize;

 

screenSize = new Vector2(ScreenWidth, ScreenHeight);

}

}

 

 

 

}

 

 
Nova Entrada 30/11/2008 20:15
  lucianoJose
123 tópicos
Iniciante


Re: tutorial mappy e xna do luciano  
 linuxboy escreveu
desculpa luciano ve se agpora ficou bom !


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Audio;

using Microsoft.Xna.Framework.Content;

using Microsoft.Xna.Framework.GamerServices;

using Microsoft.Xna.Framework.Graphics;

using Microsoft.Xna.Framework.Input;

using Microsoft.Xna.Framework.Media;

using Microsoft.Xna.Framework.Net;

using Microsoft.Xna.Framework.Storage;

using LoaderMapFromMappy;

 

 

namespace arkanoidxna

{

///

/// This is the main type for your game

///

public class Game1 : Microsoft.Xna.Framework.Game

{

GraphicsDeviceManager graphics;

SpriteBatch spriteBatch;

 

clsSprite myBase; // sprite para a basse

clsSprite myBall; // sprite para a bolinha

clsSprite[] myBackground = new clsSprite[10]; //sprite para a imagem de fundo ou telas

 

 

private MappyLoader mappyLoader;

private MapLayer mapLayer;

 

 

 

public Game1()

{

graphics = new GraphicsDeviceManager(this);

Content.RootDirectory = "Content";

}

 

///

/// Allows the game to perform any initialization it needs to before starting to run.

/// This is where it can query for any required services and load any non-graphic

/// related content. Calling base.Initialize will enumerate through any components

/// and initialize them as well.

///

protected override void Initialize()

{

// TODO: Add your initialization logic here

 

this.mappyLoader = new MappyLoader();

this.mapLayer = new MapLayer(this);

 

base.Initialize();

}

 

///

/// LoadContent will be called once per game and is the place to load

/// all of your content.

///

protected override void LoadContent()

{

// Create a new SpriteBatch, which can be used to draw textures.

 

this.spriteBatch = new SpriteBatch(GraphicsDevice);

 

this.Services.AddService(typeof(SpriteBatch), this.spriteBatch);

 

this.mapLayer.LoadContent("mapa1.FMP", this.mappyLoader);

 

this.mapLayer.TileStripTexture = this.Content.Load<Texture2D>("tilebloco");

 

this.mapLayer.BuildSourceRectanglesTileStrip(3, 2, 5);

 

 

 

 

myBase = new clsSprite(Content.Load<Texture2D>("base-arkanoide"),

new Vector2(280f, 570f), new Vector2(64f, 64f),

graphics.PreferredBackBufferWidth,

graphics.PreferredBackBufferHeight);

 

myBall = new clsSprite(Content.Load<Texture2D>("bolinha"),

new Vector2(365f, 540f), new Vector2(64f, 64f),

graphics.PreferredBackBufferWidth,

graphics.PreferredBackBufferHeight);

 

graphics.PreferredBackBufferWidth = 800;

graphics.PreferredBackBufferHeight = 600;

graphics.ApplyChanges();

 

 

 

 

 

 

 

// Create a new SpriteBatch, which can be used to draw textures.

spriteBatch = new SpriteBatch(GraphicsDevice);

 

}

 

///

/// UnloadContent will be called once per game and is the place to unload

/// all content.

///

protected override void UnloadContent()

{

// TODO: Unload any non ContentManager content here

}

 

///

/// Allows the game to run logic such as updating the world,

/// checking for collisions, gathering input, and playing audio.

///

/// Provides a snapshot of timing values.

protected override void Update(GameTime gameTime)

{

// Allows the game to exit

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

this.Exit();

 

// TODO: Add your update logic here

 

base.Update(gameTime);

}

 

///

/// This is called when the game should draw itself.

///

/// Provides a snapshot of timing values.

protected override void Draw(GameTime gameTime)

{

 

 

// TODO: Add your drawing code here

 

this.graphics.GraphicsDevice.Clear(Color.Black);

 

this.spriteBatch.Begin();

this.mapLayer.Draw(gameTime);

this.spriteBatch.End();

spriteBatch.Draw(myBall.texture, myBall.position, Color.White);

spriteBatch.Draw(myBase.texture, myBase.position, Color.White);

base.Draw(gameTime);

 

 

 

 

 

 

}

}

 

class clsSprite

{

public Texture2D texture; // plano de fundo

public Vector2 position; // posição do desenho

public Vector2 size; // tamanho do desenho em pixels

public Vector2 screenSize; // tamanho da tela

public Vector2 velocity; // velocidade do movimento

 

 

// controle de velocidade do objeto

 

public void Move()

{

// if we'll move out of the screen, invert velocity

// checking right boundary

if (position.X + size.X + velocity.X > screenSize.X)

velocity.X = -velocity.X;

// checking bottom boundary

if (position.Y + size.Y + velocity.Y > screenSize.Y)

velocity.Y = -velocity.Y;

// checking left boundary

if (position.X + velocity.X < 0)

velocity.X = -velocity.X;

// checking bottom boundary

if (position.Y + velocity.Y < 0)

velocity.Y = -velocity.Y;

// since we adjusted the velocity, just add it to the current position

position += velocity;

}

 

public clsSprite(Texture2D newTexture, Vector2 newPosition, Vector2 newSize, int ScreenWidth, int ScreenHeight)

{

texture = newTexture;

position = newPosition;

size = newSize;

 

screenSize = new Vector2(ScreenWidth, ScreenHeight);

}

}

 

 

 

}

 




e ai linuxboy tá tudo rodando direitinho?

Só avisando a todos já está pronta a versão 2.0 do Leitor de Mapas do Mappy e eu acho que da versão 1.0 para a 2.0, as coisas mudaram da água para o vinho. Do ponto de vista de usabilidade, arquitetura, etc melhorou mesmo! Se vocês tiverem uma opnião diferente da minha, por favor, escrevam :D

Estarei liberando a nova versão em breve!

MCP, MCTS. Administrador do SharpGames. Game Developer(C++) at Manifesto Game Studio Meu Blog: lucianojosefj.spaces.live.com