
File Template.cs:
- Code: Select all
using System;
using System.Data;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Brume;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using Ode;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using Pipo;
using ObjetosColision;
namespace BrumeTemplate
{
class Template : Pipo.Pipo
{
BrumeCamera Camara;
BrumeFont testFont = null;
Pipo.Interface.Button MiBoton = null;
Pipo.Interface.Button MiBoton2 = null;
Pipo.Interface.Container SokoORT = null;
BrumeXMesh MiMeshPlano = null;
BrumeLightedObject[] Plano;
ObjetoColision MiObjetoColision = null;
ObjetoColision MiObjetoColision2 = null;
ObjetoColision MiObjetoColision3 = null;
ObjetoColision MiObjetoColision4 = null;
ObjetoColision MiObjetoColision5 = null;
BrumeXMesh MeshTarget = null;
BrumeXMesh MeshCubo = null;
BrumeXMesh MeshPlayer = null;
float velocity = 5.0f;
int i;
bool start = false;
public Template()
: base()
{
BrumeFileManager.AddDirForAll("Data");
this.Text = "Sokoban";
//BrumeSplashScreen.ShowSplashScreen(this, "Loading...", Bitmap.FromFile(BrumeFileManager.GetFullPathForData("Loading.jpg")));
}
override protected void GameInit()
{
Camara = new BrumeCamera(this, "Camara");
this.SetActiveCamera(Camara);
BrumeTexture asd = new BrumeTexture(this, "sokort.png");
asd.HasAlpha = true;
SokoORT = new Pipo.Interface.Container(this, "SokoORT", null);
SokoORT.setSize(500, 177);
SokoORT.setTexture(asd);
SokoORT.setPosition(272, 36);
SokoORT.setTransparency(true);
//Pipo.Interface.Panel MiPanel = new Pipo.Interface.Panel(this, "Panel", null);
MiBoton = new Pipo.Interface.Button(this,"Boton",null);
MiBoton.setTextureName("newgame_button");
MiBoton.setSize(156,78);
MiBoton.setPosition(438, 261);
MiBoton.buttonPressedEvent += new Pipo.Interface.Button.EventDelegate(MiBoton_OnClick);
MiBoton2 = new Pipo.Interface.Button(this, "Boton2", null);
MiBoton2.setTextureName("exit_button");
MiBoton2.setSize(156, 78);
MiBoton2.setPosition(438, 436);
MiBoton2.buttonPressedEvent += new Pipo.Interface.Button.EventDelegate(MiBoton2_OnClick);
}
public void MiBoton2_OnClick()
{
this.Close();
}
public void MiBoton_OnClick()
{
MiBoton.setVisible(false);
MiBoton2.setVisible(false);
SokoORT.setVisible(false);
SetLvl1();
}
public void SetLvl1()
{
MiMeshPlano = new BrumeXMesh(this, "Plano", "floor.x", false);
MeshPlayer = new BrumeXMesh(this, "Player", "player.x", false);
MeshCubo = new BrumeXMesh(this, "Cube", "box.x", false);
MeshTarget = new BrumeXMesh(this, "Target", "cross.x", false);
BrumeVector cameraPos = new BrumeVector(5.88f, 43.7f, -38.38f);
BrumeVector cameraDir = new BrumeVector(0.012f, -0.68f, 0.73f);
BrumeVector cameraUp = new BrumeVector(0.006f, 0.73f, 0.68f);
Camara.Pos = cameraPos;
Camara.Dir = cameraDir;
Camara.Up = cameraUp;
Plano = new BrumeLightedObject[16];
for (i = 0; i <= Plano.Length - 1; i++)
{
Plano[i] = new BrumeLightedObject(this, "Plano " + Convert.ToString(i));
Plano[i].Mesh = MiMeshPlano;
}
Plano[0].Mesh = MeshTarget;
Plano[3].Mesh = MeshTarget;
Plano[12].Mesh = MeshTarget;
Plano[15].Mesh = MeshTarget;
Plano[0].Pos = new BrumeVector(0.0f, 0.0f, 0.0f);
Plano[1].Pos = new BrumeVector(0.0f, 0.0f, 5.0f);
Plano[2].Pos = new BrumeVector(0.0f, 0.0f, 10.0f);
Plano[3].Pos = new BrumeVector(0.0f, 0.0f, 15.0f);
Plano[4].Pos = new BrumeVector(5.0f, 0.0f, 0.0f);
Plano[5].Pos = new BrumeVector(5.0f, 0.0f, 5.0f);
Plano[6].Pos = new BrumeVector(5.0f, 0.0f, 10.0f);
Plano[7].Pos = new BrumeVector(5.0f, 0.0f, 15.0f);
Plano[8].Pos = new BrumeVector(10.0f, 0.0f, 0.0f);
Plano[9].Pos = new BrumeVector(10.0f, 0.0f, 5.0f);
Plano[10].Pos = new BrumeVector(10.0f, 0.0f, 10.0f);
Plano[11].Pos = new BrumeVector(10.0f, 0.0f, 15.0f);
Plano[12].Pos = new BrumeVector(15.0f, 0.0f, 0.0f);
Plano[13].Pos = new BrumeVector(15.0f, 0.0f, 5.0f);
Plano[14].Pos = new BrumeVector(15.0f, 0.0f, 10.0f);
Plano[15].Pos = new BrumeVector(15.0f, 0.0f, 15.0f);
#region Cubos
MiObjetoColision = new ObjetoColision(this, MeshPlayer, new BrumeVector(10.0f, 3.0f, 5.0f), Cubo_CollisionEvent, "Cubo");
MiObjetoColision.Pos -= new BrumeVector(0.0f, 1.0f, 0.0f);
MiObjetoColision2 = new ObjetoColision(this, MeshCubo, new BrumeVector(0.0f, 3.0f, 5.0f), Cubo2_CollisionEvent, "Cubo2");
MiObjetoColision2.Pos -= new BrumeVector(0.0f, 1.0f, 0.0f);
MiObjetoColision3 = new ObjetoColision(this, MeshCubo, new BrumeVector(5.0f, 3.0f, 10.0f), Cubo3_CollisionEvent, "Cubo3");
MiObjetoColision3.Pos -= new BrumeVector(0.0f, 1.0f, 0.0f);
MiObjetoColision4 = new ObjetoColision(this, MeshCubo, new BrumeVector(10.0f, 3.0f, 10.0f), Cubo4_CollisionEvent, "Cubo4");
MiObjetoColision4.Pos -= new BrumeVector(0.0f, 1.0f, 0.0f);
MiObjetoColision5 = new ObjetoColision(this, MeshCubo, new BrumeVector(10.0f, 3.0f, 0.0f), Cubo5_CollisionEvent, "Cubo5");
MiObjetoColision5.Pos -= new BrumeVector(0.0f, 1.0f, 0.0f);
#endregion
start = true;
}
#region Evento Colisiones
void Cubo_CollisionEvent(BrumeObject obj, BrumeCollisionShape otherShape, List<BrumeCollisionContact> contacts)
{
MiObjetoColision.MoveToLastPosition();
}
void Cubo2_CollisionEvent(BrumeObject obj, BrumeCollisionShape otherShape, List<BrumeCollisionContact> contacts)
{
if (otherShape.SourceObject.Name == "Cubo")
{
if (BrumeKeyboard.IsPressed(BrumeKey.W))
{
if (MiObjetoColision2.Pos.Z == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision2.Pos += MiObjetoColision2.Dir * velocity;
if (MiObjetoColision2.Pos.Z > 15.0f)
{
MiObjetoColision2.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.S))
{
if (MiObjetoColision2.Pos.Z == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision2.Pos += -MiObjetoColision2.Dir * velocity;
if (MiObjetoColision2.Pos.Z < 0.0f)
{
MiObjetoColision2.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.A))
{
if (MiObjetoColision2.Pos.X == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision2.Pos += -MiObjetoColision2.Right * velocity;
if (MiObjetoColision2.Pos.X < 0.0f)
{
MiObjetoColision2.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.D))
{
if (MiObjetoColision2.Pos.X == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision2.Pos += MiObjetoColision2.Right * velocity;
if (MiObjetoColision2.Pos.X > 15.0f)
{
MiObjetoColision2.MoveToLastPosition();
}
}
}
else
{
MiObjetoColision2.MoveToLastPosition();
}
}
void Cubo3_CollisionEvent(BrumeObject obj, BrumeCollisionShape otherShape, List<BrumeCollisionContact> contacts)
{
if (otherShape.SourceObject.Name == "Cubo")
{
if (BrumeKeyboard.IsPressed(BrumeKey.W))
{
if (MiObjetoColision3.Pos.Z == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision3.Pos += MiObjetoColision2.Dir * velocity;
if (MiObjetoColision3.Pos.Z > 15.0f)
{
MiObjetoColision3.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.S))
{
if (MiObjetoColision3.Pos.Z == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision3.Pos += -MiObjetoColision2.Dir * velocity;
if (MiObjetoColision3.Pos.Z < 0.0f)
{
MiObjetoColision3.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.A))
{
if (MiObjetoColision3.Pos.X == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision3.Pos += -MiObjetoColision2.Right * velocity;
if (MiObjetoColision3.Pos.X < 0.0f)
{
MiObjetoColision3.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.D))
{
if (MiObjetoColision3.Pos.X == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision2.Pos += MiObjetoColision2.Right * velocity;
if (MiObjetoColision3.Pos.X > 15.0f)
{
MiObjetoColision3.MoveToLastPosition();
}
}
}
else
{
MiObjetoColision3.MoveToLastPosition();
}
}
void Cubo4_CollisionEvent(BrumeObject obj, BrumeCollisionShape otherShape, List<BrumeCollisionContact> contacts)
{
if (otherShape.SourceObject.Name == "Cubo")
{
if (BrumeKeyboard.IsPressed(BrumeKey.W))
{
if (MiObjetoColision4.Pos.Z == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision4.Pos += MiObjetoColision2.Dir * velocity;
if (MiObjetoColision4.Pos.Z > 15.0f)
{
MiObjetoColision4.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.S))
{
if (MiObjetoColision4.Pos.Z == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision4.Pos += -MiObjetoColision2.Dir * velocity;
if (MiObjetoColision4.Pos.Z < 0.0f)
{
MiObjetoColision4.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.A))
{
if (MiObjetoColision4.Pos.X == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision4.Pos += -MiObjetoColision2.Right * velocity;
if (MiObjetoColision4.Pos.X < 0.0f)
{
MiObjetoColision4.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.D))
{
if (MiObjetoColision4.Pos.X == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision4.Pos += MiObjetoColision2.Right * velocity;
if (MiObjetoColision4.Pos.X > 15.0f)
{
MiObjetoColision4.MoveToLastPosition();
}
}
}
else
{
MiObjetoColision4.MoveToLastPosition();
}
}
void Cubo5_CollisionEvent(BrumeObject obj, BrumeCollisionShape otherShape, List<BrumeCollisionContact> contacts)
{
if (otherShape.SourceObject.Name == "Cubo")
{
if (BrumeKeyboard.IsPressed(BrumeKey.W))
{
if (MiObjetoColision5.Pos.Z == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision5.Pos += MiObjetoColision2.Dir * velocity;
if (MiObjetoColision5.Pos.Z > 15.0f)
{
MiObjetoColision5.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.S))
{
if (MiObjetoColision5.Pos.Z == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Dir * velocity;
}
if (MiObjetoColision.Pos.Z < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision5.Pos += -MiObjetoColision2.Dir * velocity;
if (MiObjetoColision5.Pos.Z < 0.0f)
{
MiObjetoColision5.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.A))
{
if (MiObjetoColision5.Pos.X == 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += -MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision5.Pos += -MiObjetoColision2.Right * velocity;
if (MiObjetoColision5.Pos.X < 0.0f)
{
MiObjetoColision5.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.D))
{
if (MiObjetoColision5.Pos.X == 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
else
{
MiObjetoColision.Pos += MiObjetoColision.Right * velocity;
}
if (MiObjetoColision.Pos.X > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
MiObjetoColision5.Pos += MiObjetoColision2.Right * velocity;
if (MiObjetoColision5.Pos.X > 15.0f)
{
MiObjetoColision5.MoveToLastPosition();
}
}
}
else
{
MiObjetoColision5.MoveToLastPosition();
}
}
void MiObjeto_CollisionEvent(BrumeObject obj, BrumeCollisionShape otherShape, List<BrumeCollisionContact> contacts)
{
}
#endregion
protected override void MoveScene(float fElapsedTime)
{
if (start == true)
{
if (Camara != null && this.DebugConsole.debugLevel != 2)
{
if (BrumeKeyboard.IsPressedDelayed(BrumeKey.W, fElapsedTime))
{
MiObjetoColision.Pos += MiObjetoColision.Dir * velocity;
if (MiObjetoColision.Pos.Z > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressedDelayed(BrumeKey.S, fElapsedTime))
{
MiObjetoColision.Pos += -MiObjetoColision.Dir * velocity;
if (MiObjetoColision.Pos.Z < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressedDelayed(BrumeKey.A, fElapsedTime))
{
MiObjetoColision.Pos += -MiObjetoColision.Right * velocity;
if (MiObjetoColision.Pos.X < 0.0f)
{
MiObjetoColision.MoveToLastPosition();
}
}
else if (BrumeKeyboard.IsPressedDelayed(BrumeKey.D, fElapsedTime))
{
MiObjetoColision.Pos += MiObjetoColision.Right * velocity;
if (MiObjetoColision.Pos.X > 15.0f)
{
MiObjetoColision.MoveToLastPosition();
}
}
}
}
}
public static void Main()
{
using (Template game = new Template())
{
game.Play();
}
}
}
}
File Class1.cs
- Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using Brume;
namespace ObjetosColision
{
public class ObjetoColision
{
BrumeObject myRoot;
BrumeLightedObject myLightedObject;
BrumeCubeColored myCube;
BrumeXMesh myMesh;
public ObjetoColision(Brume.Brume brume, BrumeXMesh mesh, BrumeVector pos, BrumeCollisionDelegate CollissionEvent, string name)
{
myMesh = mesh;
myRoot = new BrumeObject(brume, name);
myLightedObject = new BrumeLightedObject(brume, name);
myLightedObject.Mesh = myMesh;
myLightedObject.Pos = new BrumeVector(0.0f, pos.Y, 0.0f);
myRoot.AddChild(myLightedObject);
myCube = new BrumeCubeColored(brume, name);
myCube.Pos = myLightedObject.Pos;
myCube.AddCollisionShapes(brume.GenerateCollisionShapes(myCube));
myCube.CollisionEvent += new BrumeCollisionDelegate(CollissionEvent);
myCube.Mesh = null;
myRoot.AddChild(myCube);
myRoot.Pos = pos;
myRoot.ForcedVisibility = true;
myLightedObject.ForcedVisibility = true;
}
public void MoveToLastPosition()
{
myRoot.MoveToLastPosition();
}
public bool Visible
{
get
{
return myRoot.ForcedVisibilityState;
}
set
{
myRoot.ForcedVisibilityState = value;
myLightedObject.ForcedVisibilityState = value;
}
}
public BrumeVector Pos
{
get
{
return myRoot.Pos;
}
set
{
myRoot.Pos = value;
}
}
public BrumeVector Dir
{
get
{
return myRoot.Dir;
}
set
{
myRoot.Dir = value;
}
}
public BrumeVector Right
{
get
{
return myRoot.Right;
}
set
{
myRoot.Right = value;
}
}
public float CollissionAreaSize
{
get
{
return myCube.Size;
}
set
{
myCube.Size = value;
}
}
public float ObjectSize
{
get
{
return myLightedObject.Size;
}
set
{
myLightedObject.Size = value;
}
}
~ObjetoColision()
{
}
}
}
The program with the resources can be downloaded from here: http://www.mediafire.com/download.php?hwwnyjmgldy
Thanks.