Daniele Bartolini 13 лет назад
Родитель
Сommit
7d79dfcbbe

+ 0 - 4
samples/chainsawbuffet/Globals.cpp

@@ -1,4 +0,0 @@
-#include "Globals.h"
-#include "Joystick.h"
-
-Joystick* Globals::joystick = NULL;

+ 0 - 24
samples/chainsawbuffet/Globals.h

@@ -1,24 +0,0 @@
-#ifndef __GLOBALS_H__
-#define __GLOBALS_H__
-
-class Joystick;
-
-enum CollisionGroups
-{
-	CG_NONE = 0,
-	CG_ZOMBIE = 1,
-	CG_PG = 2,
-	CG_BULLET = 3,
-	CG_WALL = 4
-};
-
-class Globals
-{
-public:
-	static Joystick* joystick;
-
-private:
-	Globals() {};
-};
-
-#endif //__GLOBALS_H__

+ 0 - 41
samples/chainsawbuffet/design.txt

@@ -1,41 +0,0 @@
- - Chainsaw Buffet - 
- Le seguenti sono idee per fare brainstorming.
- 
- Che cosa deve colpire del gioco: ?violenza?
- Che cosa invoglia a giocare: Completare i livelli per sbloccare altre modalità, Achievements, Storia di fondo tra i livelli
- Importante: Ricordare che il target sono smartphone, partite possibilmente brevi ed intense
- 
- Idee di zombie:				Dove si trova				Descrizione
- - Zombie normale				un pò da per tutto			Uno zombie normale che prosegue lentamente
- - Zombie veloce				un pò da per tutto			Come quello normale, ma zoppica velocemente
- - Zombie corridore				un pò da per tutto			Corre velocemente, attacca graffiando
- - Zombie maniaco				Manicomio, ospedale			Abbastanza veloce, decidere l'attacco
- - Zombie boscaiolo				Case di montagna, bosco		non molto veloce, attacca con la motosega e fa molto male
- - Zombie poliziotto			Città						Velocità normale, attacca con la pistola o il manganello
- 
- Modalità di gioco:
- - Survival classico: Si sceglie uno scenario e si sopravvive alle ondate.
- - Avventura: Una quantità di scenari successivi sbloccabili ultimandoli in sequenza.
-   > Ogni scenario si può ripetere in diverse modalità:
-    Ricerca: Bisogna cercare tre oggetti prestabiliti che sono da qualche parte nello scenario o droppati da qualche mostro.
-    Salvataggio: Andare a prendere e portare fuori un personaggio intrappolato.
-	Pulizia: Ucciderne più possibile in un dato tempo. Si trovano power up in giro per la mappa per aumentare la violenza.
-	Difesa della campana: in un posto della mappa c'è una campana da difendere per un determinato tempo. Dopo tre rintocchi si fallisce.
-	
- Gli scenari della modalità Survival devono essere prima sbloccati nella modalità Avventura
- 
- L'uccisione di diversi mostri di fila aumenta il livello di combo, il passare del tempo lo diminuisce. Raggiunto il livello massimo, si può attivare la modalità Bloodlust (berserk con motosega)
- 
- 
- Roadmap:
- 1.  Personaggio su schermo che si muove con wasd e punta verso il movimento [ok]
- 2.  Joystick touch da trascinare col mouse [ok]
- 3.  Grafica con cerchi e quadrati di abbozzo animazioni pg camminata, caricamento arma, altro... per provare sistema di animazione [ok]
- 4.  Zombie normale con animazione camminata e attacco
- 5.  Barile
- 6.  Sistema fisico per gestire le collisioni tra zombie, pg e oggetti (barile)
- 7.  Muri (rettangoli in pratica, simile al barile)
- 8.  Abbozzo di ia zombie, ti insegue se ti vede sennò girovaga. Non vede attraverso i muri
- 9.  Pistola con proiettili, collisione di oggetto ad alta velocità con oggetti e zombie
- 10. Animazioni di colpito dello zombie (e del pg?)
- 

+ 0 - 22
samples/chainsawbuffet/entities/Background.cpp

@@ -1,22 +0,0 @@
-#include "Background.h"
-
-Background::Background(Scene* scene, SceneNode* parent, real x, real y):
-	SceneNode(scene, parent, Vec3(x, y, 0), Angles(0, 0, 0), true)
-{
-	mBgSprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/tiles.bmp");
-}
-
-Background::~Background()
-{
-}
-
-void Background::Update(real dt)
-{
-	SceneNode::Update(dt);
-}
-
-void Background::Render()
-{
-	SceneNode::Render();
-	mBgSprite->draw(0, 0.0, 1.0, 1.0);
-}

+ 0 - 21
samples/chainsawbuffet/entities/Background.h

@@ -1,21 +0,0 @@
-#ifndef __BACKGROUND_H__
-#define __BACKGROUND_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class Background: public SceneNode
-{
-public:
-	Background(Scene* scene, SceneNode* parent, real x, real y);
-	virtual ~Background();
-
-	virtual void Update(real dt);
-	virtual void Render();
-
-private:
-	Auto<Sprite> mBgSprite;
-};
-
-#endif //__BACKGROUND_H__

+ 0 - 57
samples/chainsawbuffet/entities/Bullet.cpp

@@ -1,57 +0,0 @@
-#include "Bullet.h"
-#include "Globals.h"
-#include "Joystick.h"
-#include "ArenaScene.h"
-
-Bullet::Bullet(Scene* scene, SceneNode* parent, real x, real y, Vec3 direction, real speed):
-	PhysicNode(scene, parent, Vec3(x, y, 0), Angles(0, 0, 0), true, CG_BULLET), mHasCollided(false)
-{
-	//Load the body sprite
-	mTrailSprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/bullets.bmp", "res/chainsawbuffet/bullets_alpha.bmp", 1, 1, 1, 1, 1, 10, 3, 0, 0);
-	for(int i = 0; i < mTrailSprite->GetFrameCount(); i++)
-	{
-		mTrailSprite->GetFrame(i)->SetOffset(0, 1);
-	}
-	mTrailSprite->SetInterpolation(true);
-	mTrailSpriteAnimator.SetSprite(mTrailSprite.GetPointer());
-	mTrailSpriteAnimator.SetFrameInterval(0);
-	mTrailSpriteAnimator.SetScaleX(6);
-
-	SetUseIntegerCoordinatesForRendering(true);
-
-	SetVelocity(direction * speed);
-
-	Circle* c = new Circle(Vec2::ZERO, 2);
-	//SetShape(c);
-}
-
-Bullet::~Bullet()
-{
-}
-
-void Bullet::Collision(PhysicNode* other)
-{
-	if (!mHasCollided)
-	{
-		mHasCollided = true;
-		ArenaScene* arena = (ArenaScene*)GetCreator();
-		ParticleManager* manager = arena->GetParticleManager();
-		manager->AddEmitter(new ParticleEmitter(mPosition, 0.01, 0.2, GetVelocity().ToVec2().GetAngle() + Math::PI, Math::PI / 6));
-		SetVelocity(Vec3::ZERO);
-	}
-}
-
-void Bullet::Update(real dt)
-{
-	mTrailSpriteAnimator.SetAngle(GetVelocity().ToVec2().GetAngle() + Math::PI);
-	PhysicNode::Update(dt);
-}
-
-void Bullet::Render()
-{
-	PhysicNode::Render();
-	Renderer* r = GetDevice()->GetRenderer();
-	mTrailSpriteAnimator.Render();
-	r->DrawRectangle(Point2(-1, -1), Point2(2, 2), DM_FILL, Color4::BLACK, Color4::BLACK);
-	//mBodySpriteAnimator.Render();
-}

+ 0 - 24
samples/chainsawbuffet/entities/Bullet.h

@@ -1,24 +0,0 @@
-#ifndef __BULLET_H__
-#define __BULLET_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class Bullet: public PhysicNode
-{
-public:
-	Bullet(Scene* scene, SceneNode* parent, real x, real y, Vec3 direction, real speed);
-	virtual ~Bullet();
-
-	virtual void Update(real dt);
-	virtual void Render();
-	virtual void Collision(PhysicNode* other);
-
-private:
-	Auto<Sprite> mTrailSprite;
-	SpriteAnimator mTrailSpriteAnimator;
-	bool mHasCollided;
-};
-
-#endif //__BULLET_H__

+ 0 - 69
samples/chainsawbuffet/entities/Joystick.cpp

@@ -1,69 +0,0 @@
-#include "Joystick.h"
-#include "Globals.h"
-
-Joystick::Joystick(Scene* scene, Camera* camera):
-	SolidSceneNode(scene, NULL,  Vec3(0, 0, 0), Angles(0, 0, 0), true, CG_NONE), mDragging(false), 
-	mInitialPosition(80, 400, 0), mMouseStartDragPosition(0, 0, 0),
-	mDelta(0, 0, 0)
-{
-	Globals::joystick = this;
-	mJoystickSprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/joystick.bmp");
-	mJoystickSprite->GetFrame(0)->SetOffset(64, 64);
-
-	mPosition = mInitialPosition;
-
-	GetDevice()->GetInputManager()->RegisterMouseListener(this);
-}
-
-Joystick::~Joystick()
-{
-	Globals::joystick = NULL;
-	//delete mBodySprite;
-}
-
-const Vec3& Joystick::GetDelta() const
-{
-	return mDelta;
-}
-
-void Joystick::Render()
-{
-	//Do an update
-	mPosition = mInitialPosition + mDelta;
-
-	SolidSceneNode::Render();
-	mJoystickSprite->draw(0);
-}
-
-void Joystick::ButtonPressed(const MouseEvent& event)
-{
-	if (event.button == MB_LEFT)
-	{
-		Point2 mousePosition = GetDevice()->GetInputManager()->GetMouse()->GetCursorXY();
-		mMouseStartDragPosition = Vec3((real)mousePosition.x, (real)mousePosition.y, 0.0);
-
-		mDragging = ((mMouseStartDragPosition - mInitialPosition).GetSquaredLength() <= 60*60);
-	}
-}
-
-void Joystick::ButtonReleased(const MouseEvent& event)
-{
-	if (event.button == MB_LEFT)
-	{
-		mDragging = false;
-		mDelta = Vec3::ZERO;
-	}
-}
-
-void Joystick::CursorMoved(const MouseEvent& event)
-{
-	if (mDragging)
-	{
-		mDelta = GetDevice()->GetInputManager()->GetMouse()->GetCursorXY().ToVec3() - mMouseStartDragPosition;
-		if (mDelta.GetSquaredLength() > 900)
-		{
-			mDelta = mDelta.Normalize() * 30;
-		}
-	}
-}
-

+ 0 - 31
samples/chainsawbuffet/entities/Joystick.h

@@ -1,31 +0,0 @@
-#ifndef __JOYSTICK_H__
-#define __JOYSTICK_H__
-
-#include "SolidSceneNode.h"
-
-using namespace Crown;
-
-class Joystick: public SolidSceneNode, public MouseListener
-{
-public:
-	Joystick(Scene* scene, Camera* camera);
-	virtual ~Joystick();
-
-	virtual void Render();
-
-	virtual void ButtonPressed(const MouseEvent& event);
-	virtual void ButtonReleased(const MouseEvent& event);
-	virtual void CursorMoved(const MouseEvent& event);
-
-	//! Returns the Joystick delta
-	const Vec3& GetDelta() const;
-
-private:
-	Auto<Sprite> mJoystickSprite;
-	bool mDragging;
-	Vec3 mInitialPosition;
-	Vec3 mMouseStartDragPosition;
-	Vec3 mDelta;
-};
-
-#endif //__JOYSTICK_H__

+ 0 - 161
samples/chainsawbuffet/entities/Pg.cpp

@@ -1,161 +0,0 @@
-#include "Pg.h"
-#include "Globals.h"
-#include "Joystick.h"
-#include "Bullet.h"
-#include "ArenaScene.h"
-
-Pg::Pg(Scene* scene, Camera* camera):
-	PhysicNode(scene, camera, Vec3(400, 240, 0), Angles(0, 0, 0), true, CG_PG),
-	mSpeed(0.0), mDirection(1.0, 0.0, 0.0), mIsReloading(false), mBulletCounter(0), mBulletInterval(30)
-{
-	//Load the body sprite
-	mBodySprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/pg_body.bmp", 4, 1, 4, 0, 0, 46, 36, 0, 0);
-	for(int i = 0; i < mBodySprite->GetFrameCount(); i++)
-	{
-		mBodySprite->GetFrame(i)->SetOffset(13, 16);
-	}
-	mBodySprite->SetInterpolation(true);
-	mBodySpriteAnimator.SetSprite(mBodySprite.GetPointer());
-	mBodySpriteAnimator.SetFrameInterval(0);
-
-	//Load the reload sprite
-	mReloadSprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/pg_body.bmp", 4, 1, 4, 0, 36, 46, 36, 0, 0);
-	for(int i = 0; i < mReloadSprite->GetFrameCount(); i++)
-	{
-		mReloadSprite->GetFrame(i)->SetOffset(13, 16);
-	}
-	mReloadSprite->SetInterpolation(true);
-	mReloadSpriteAnimator.SetSprite(mReloadSprite.GetPointer());
-	mReloadSpriteAnimator.SetFrameInterval(10);
-
-	//Load the legs sprite
-	mLegsSprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/pg_legs.bmp", 16, 2, 10, 0, 0, 12, 10, 0, 0);
-	for(int i = 0; i < mLegsSprite->GetFrameCount(); i++)
-	{
-		mLegsSprite->GetFrame(i)->SetOffset(6, 5);
-	}
-	mLegsSpriteAnimator.SetSprite(mLegsSprite.GetPointer());
-	mLegsSpriteAnimator.SetFrameInterval(100);
-	mLegsSpriteAnimator.SetScaleX((real)2.8);
-	mLegsSpriteAnimator.SetScaleY((real)2.4);
-
-	SetUseIntegerCoordinatesForRendering(true);
-	GetDevice()->GetInputManager()->RegisterKeyboardListener(this);
-
-	/*Crown::Rectangle* r = new Crown::Rectangle();
-	r->SetFromCenterAndDimensions(Vec2::ZERO, 30, 30);
-	SetShape(r);*/
-	Circle* c = new Circle(Vec2::ZERO, 15);
-	//SetShape(c);
-}
-
-Pg::~Pg()
-{
-	//delete mBodySprite;
-}
-
-void Pg::Update(real dt)
-{
-	//Calculate the velocity based on joystick input before the parent's update, where it will be applied
-	Vec3 delta = Globals::joystick->GetDelta();
-	delta.y = -delta.y;
-	mSpeed = delta.GetLength() * (real)1.9;
-	if (mSpeed >= 0.001)
-	{
-		delta.Normalize();
-		mDirection = delta;
-	}
-	SetVelocity(mDirection * mSpeed * 3.5);
-
-	UpdateSpriteAnimators(dt);
-
-	if (mBulletCounter > 0)
-	{
-		mBulletCounter -= 1;
-	}
-
-	ArenaScene* arena = (ArenaScene*)GetCreator();
-	arena->GetMainCamera()->SetPosition(Vec3(mPosition.x, mPosition.y, arena->GetMainCamera()->GetPosition().z));
-
-	PhysicNode::Update(dt);
-}
-
-void Pg::UpdateSpriteAnimators(real dt)
-{
-	if (mSpeed > 0.01)
-	{
-		//2.8 is the x scale of the legs sprite
-		real legWalkDistancePixels = (real)(18 * 2.8);
-		real secondsToWalkLegDistance = legWalkDistancePixels / mSpeed;
-		real legFrameDurationSeconds = secondsToWalkLegDistance / mLegsSprite->GetFrameCount();
-		real bodyFrameDurationSeconds = secondsToWalkLegDistance / mBodySprite->GetFrameCount();
-		mLegsSpriteAnimator.SetFrameInterval((int)(GetDevice()->GetActualFps() * legFrameDurationSeconds));
-		mBodySpriteAnimator.SetFrameInterval((int)(GetDevice()->GetActualFps() * bodyFrameDurationSeconds));
-	}
-	else
-	{
-		mLegsSpriteAnimator.SetFrameInterval(0);
-		mLegsSpriteAnimator.SetFrameIndex(0);
-		mBodySpriteAnimator.SetFrameInterval(0);
-		mBodySpriteAnimator.SetFrameIndex(0);
-	}
-
-	real angle = mDirection.ToVec2().GetAngle();
-	mBodySpriteAnimator.SetAngle(angle);
-	mReloadSpriteAnimator.SetAngle(angle);
-	mLegsSpriteAnimator.SetAngle(angle);
-}
-
-void Pg::Render()
-{
-	PhysicNode::Render();
-	mLegsSpriteAnimator.Render();
-	if (mIsReloading)
-	{
-		mReloadSpriteAnimator.Render();
-		if (mReloadSpriteAnimator.GetFrameIndex() == 3)
-		{
-			mIsReloading = false;
-			mBodySpriteAnimator.SetFrameIndex(0);
-		}
-	}
-	else
-	{
-		mBodySpriteAnimator.Render();
-	}
-
-	//Renderer* r = GetDevice()->GetRenderer();
-	//Crown::Rectangle* rect = static_cast<Crown::Rectangle*>(GetShape());
-	//
-	//Vec2 min = rect->GetVertext(0) - mPosition.ToVec2();
-	//Vec2 size = rect->GetSize();
-	//if (mIsColliding)
-	//{
-	//	r->DrawRectangle(Point2(min.x, min.y), Point2(size.x, size.y), DM_BORDER, Color4::BLUE, Color4::BLUE);
-	//}
-	//else
-	//{
-	//	r->DrawRectangle(Point2(min.x, min.y), Point2(size.x, size.y), DM_BORDER);
-	//}
-	//mIsColliding = false;
-}
-
-void Pg::KeyPressed(const KeyboardEvent& event)
-{
-	if (event.key == 'C')
-	{
-		mIsReloading = true;
-		mReloadSpriteAnimator.SetFrameIndex(0);
-	}
-	if (event.key == ' ')
-	{
-		if (mBulletCounter == 0)
-		{
-			Vec3 pos = mPosition + mDirection * 30;
-			pos += Vec3(-mDirection.y, mDirection.x, 0.0) * 7;
-			
-			Bullet* b = new Bullet(GetCreator(), GetParent(), pos.x, pos.y, mDirection, 400);
-			mBulletCounter = mBulletInterval;
-		}
-	}
-}

+ 0 - 39
samples/chainsawbuffet/entities/Pg.h

@@ -1,39 +0,0 @@
-#ifndef __PG_H__
-#define __PG_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class Pg: public PhysicNode, public KeyboardListener
-{
-public:
-	Pg(Scene* scene, Camera* camera);
-	virtual ~Pg();
-
-	virtual void Update(real dt);
-	virtual void Render();
-
-	virtual void KeyPressed(const KeyboardEvent& event);
-
-private:
-	Auto<Sprite> mBodySprite;
-	Auto<Sprite> mReloadSprite;
-	Auto<Sprite> mLegsSprite;
-	SpriteAnimator mBodySpriteAnimator;
-	SpriteAnimator mReloadSpriteAnimator;
-	SpriteAnimator mLegsSpriteAnimator;
-	Vec3 mDirection;
-	real mSpeed;
-	bool mIsColliding;
-
-	bool mIsReloading;
-
-	//bullet handling
-	int mBulletCounter;
-	int mBulletInterval;
-
-	void UpdateSpriteAnimators(real dt);
-};
-
-#endif //__PG_H__

+ 0 - 31
samples/chainsawbuffet/entities/SolidSceneNode.cpp

@@ -1,31 +0,0 @@
-#include "SolidSceneNode.h"
-
-using namespace Crown;
-
-SolidSceneNode::SolidSceneNode(Scene* creator, SceneNode* parent, const Vec3& position, const Angles& axis, bool visible, int collisionGroupId) :
-	PhysicNode(creator, parent, position, axis, visible, collisionGroupId)
-{
-	//This code should go in SceneNode? (when moving it there, check also the factory methods in Scene, such as AddCamera, AddSceneNode...)
-	if (parent == NULL)
-	{
-		creator->GetRootSceneNode()->AddChild(this);
-	}
-}
-
-SolidSceneNode::~SolidSceneNode()
-{
-
-}
-
-void SolidSceneNode::OnRegisterForRendering()
-{
-	if (this->IsVisible())
-	{
-		if (mCreator)
-		mCreator->RegisterNodeForRendering(this, RP_GUI);
-
-		SceneNode::OnRegisterForRendering();
-	}
-}
-
-

+ 0 - 22
samples/chainsawbuffet/entities/SolidSceneNode.h

@@ -1,22 +0,0 @@
-#ifndef __SOLID_SCENE_NODE_H__
-#define __SOLID_SCENE_NODE_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class SolidSceneNode: public PhysicNode
-{
-public:
-	//! Constructor
-	SolidSceneNode(Scene* creator, SceneNode* parent, const Vec3& position, const Angles& axis, bool visible, int collisionGroupId);
-
-	//! Destructor
-	virtual ~SolidSceneNode();
-
-	//! Tasks to perform when registering the node for rendering
-	virtual void OnRegisterForRendering();
-};
-
-#endif // __SOLID_SCENE_NODE_H__
-

+ 0 - 94
samples/chainsawbuffet/entities/Wall.cpp

@@ -1,94 +0,0 @@
-#include "Wall.h"
-#include "Globals.h"
-#include "Joystick.h"
-#include <GL/glew.h>	// FIXME
-
-Wall::Wall(Scene* scene, Camera* camera, real x, real y, real w, real h):
-	PhysicNode(scene, camera, Vec3(x, y, 0), Angles(0, 0, 0), true, CG_WALL)
-{
-	mStoneTexture = GetTextureManager()->Load("res/chainsawbuffet/stone_wall_texture.bmp");
-
-	SetUseIntegerCoordinatesForRendering(true);
-
-	Crown::Rect* r = new Crown::Rect();
-	r->SetFromCenterAndDimensions(Vec2::ZERO, w+5, h+5);
-	//SetShape(r);
-
-	SetInverseMass(0.0);
-
-	bool meshCreated;
-	mMesh = GetMeshManager()->Create("wall_mesh", meshCreated);
-
-	if (mMesh != NULL && meshCreated)
-	{
-		MeshChunk* chunk = new MeshChunk();
-		real halfSizeX, halfSizeY;
-		real sizeZ;
-		halfSizeX = w/2;
-		halfSizeY = h/2;
-		sizeZ = 80;
-		real texWidth = 512;
-		real texHeight = 512;
-		//Ceiling Face
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX, -halfSizeY, sizeZ), Vec3::ZAXIS, Vec2(                  0.0f,                    0.0f)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX, -halfSizeY, sizeZ), Vec3::ZAXIS, Vec2(halfSizeX*2 / texWidth,                    0.0f)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX,  halfSizeY, sizeZ), Vec3::ZAXIS, Vec2(halfSizeX*2 / texWidth, halfSizeY*2 / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX,  halfSizeY, sizeZ), Vec3::ZAXIS, Vec2(                  0.0f, halfSizeY*2 / texHeight)));
-		
-		//Right Face
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX,  halfSizeY,   0.0), Vec3::XAXIS, Vec2(halfSizeY*2 / texWidth,              0.0f)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX,  halfSizeY, sizeZ), Vec3::XAXIS, Vec2(halfSizeY*2 / texWidth, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX, -halfSizeY, sizeZ), Vec3::XAXIS, Vec2(                  0.0f, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX, -halfSizeY,   0.0), Vec3::XAXIS, Vec2(                  0.0f,              0.0f)));
-
-		//Bottom Face
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX, -halfSizeY,   0.0),-Vec3::YAXIS, Vec2(halfSizeX*2 / texWidth,              0.0f)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX, -halfSizeY, sizeZ),-Vec3::YAXIS, Vec2(halfSizeX*2 / texWidth, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX, -halfSizeY, sizeZ),-Vec3::YAXIS, Vec2(                  0.0f, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX, -halfSizeY,   0.0),-Vec3::YAXIS, Vec2(                  0.0f,              0.0f)));
-
-		//Left Face
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX, -halfSizeY,   0.0),-Vec3::XAXIS, Vec2(                  0.0f,              0.0f)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX, -halfSizeY, sizeZ),-Vec3::XAXIS, Vec2(                  0.0f, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX,  halfSizeY, sizeZ),-Vec3::XAXIS, Vec2(halfSizeY*2 / texWidth, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX,  halfSizeY,   0.0),-Vec3::XAXIS, Vec2(halfSizeY*2 / texWidth,              0.0f)));
-
-		//Top Face
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX,  halfSizeY,   0.0), Vec3::YAXIS, Vec2(                  0.0f,              0.0f)));
-		chunk->mVertexList.Append(VertexData(Vec3(-halfSizeX,  halfSizeY, sizeZ), Vec3::YAXIS, Vec2(                  0.0f, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX,  halfSizeY, sizeZ), Vec3::YAXIS, Vec2(halfSizeX*2 / texWidth, sizeZ / texHeight)));
-		chunk->mVertexList.Append(VertexData(Vec3( halfSizeX,  halfSizeY,   0.0), Vec3::YAXIS, Vec2(halfSizeX*2 / texWidth,              0.0f)));
-
-		chunk->mFaceList.Append(FaceData( 0,  1,  2));
-		chunk->mFaceList.Append(FaceData( 0,  2,  3));
-		chunk->mFaceList.Append(FaceData( 4,  5,  6));
-		chunk->mFaceList.Append(FaceData( 4,  6,  7));
-		chunk->mFaceList.Append(FaceData( 8,  9, 10));
-		chunk->mFaceList.Append(FaceData( 8, 10, 11));
-		chunk->mFaceList.Append(FaceData(12, 13, 14));
-		chunk->mFaceList.Append(FaceData(12, 14, 15));
-		chunk->mFaceList.Append(FaceData(16, 17, 18));
-		chunk->mFaceList.Append(FaceData(16, 18, 19));
-
-		mMesh->AddMeshChunk(chunk);
-		mMesh->RecompileMesh();
-	}
-}
-
-Wall::~Wall()
-{
-}
-
-void Wall::Update(real dt)
-{
-	PhysicNode::Update(dt);
-}
-
-void Wall::Render()
-{
-	PhysicNode::Render();
-	Renderer* r = GetDevice()->GetRenderer();
-
-	r->SetTexture(0, mStoneTexture);
-	r->RenderVertexIndexBuffer(mMesh->GetVertexBuffer(), mMesh->GetIndexBuffer());
-}

+ 0 - 22
samples/chainsawbuffet/entities/Wall.h

@@ -1,22 +0,0 @@
-#ifndef __WALL_H__
-#define __WALL_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class Wall: public PhysicNode
-{
-public:
-	Wall(Scene* scene, Camera* camera, real x, real y, real w, real h);
-	virtual ~Wall();
-
-	virtual void Update(real dt);
-	virtual void Render();
-
-private:
-	Texture* mStoneTexture;
-	Mesh* mMesh;
-};
-
-#endif //__Wall_H__

+ 0 - 103
samples/chainsawbuffet/entities/Zombie.cpp

@@ -1,103 +0,0 @@
-#include "Zombie.h"
-#include "Pg.h"
-#include "Globals.h"
-
-Zombie::Zombie(Scene* scene, Camera* camera):
-	PhysicNode(scene, camera, Vec3(400, 240, 0), Angles(0, 0, 0), true, CG_ZOMBIE),
-	mSpeed((real)0.05), mDirection(1.0, 0.0, 0.0)
-{
-	//Load the body sprite
-	mBodySprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/zombie1.bmp", 4, 1, 4, 1, 1, 46, 36, 1, 1);
-	for(int i = 0; i < mBodySprite->GetFrameCount(); i++)
-	{
-		mBodySprite->GetFrame(i)->SetOffset(13, 16);
-	}
-	mBodySprite->SetInterpolation(true);
-	mBodySpriteAnimator.SetSprite(mBodySprite.GetPointer());
-	mBodySpriteAnimator.SetFrameInterval(30);
-	mBodySpriteAnimator.RandomizeFrameStart();
-
-	//	//Load the legs sprite
-	//mLegsSprite = Sprite::LoadSpriteFromImage("res/chainsawbuffet/Zombie_legs.bmp", 17, 2, 10, 0, 0, 12, 12, 0, 0);
-	//for(int i = 0; i < mLegsSprite->GetFrameCount(); i++)
-	//{
-	//	mLegsSprite->GetFrame(i)->SetOffset(6, 7);
-	//}
-	//mLegsSpriteAnimator.SetSprite(mLegsSprite.GetPointer());
-	//mLegsSpriteAnimator.SetFrameInterval(100);
-	//mLegsSpriteAnimator.SetScaleX(2.8);
-	//mLegsSpriteAnimator.SetScaleY(2.4);
-
-	SetUseIntegerCoordinatesForRendering(true);
-
-	mPosition.x = (real)(20 + rand() % 760);
-	mPosition.y = (real)(20 + rand() % 440);
-	mChangeDirectionInterval = rand() % 3000 + 1000;
-	real angle = (real)(Math::PI * 2 / 1000.0 * (rand() % 1000));
-	mDirection = Vec3(Math::Cos(angle), Math::Sin(angle), 0.0);
-
-	//Crown::Rectangle* r = new Crown::Rectangle();
-	//r->SetFromCenterAndDimensions(Vec2::ZERO, 30, 30);
-	//SetShape(r);
-	Circle* c = new Circle(Vec2::ZERO, 15);
-	//SetShape(c);
-}
-
-Zombie::~Zombie()
-{
-	
-}
-
-void Zombie::Collision(PhysicNode* other)
-{
-	//if (dynamic_cast<Pg*>(other) != NULL)
-	//{
-	//	Vec3 deltaPos = mPosition - other->GetPosition();
-	//	this->SetPosition(GetPosition() + deltaPos * 0.1);
-	mIsColliding = true;
-	//}
-}
-
-void Zombie::Update(real dt)
-{
-	mBodySpriteAnimator.SetFrameInterval(30/(dt*60));
-	PhysicNode::Update(dt);
-}
-
-void Zombie::Render()
-{
-	//Do an update
-	if (mChangeDirectionInterval == 0)
-	{
-		real angle = (real)(Math::PI * 2 / 1000.0 * (rand() % 1000));
-		mDirection = Vec3(Math::Cos(angle), Math::Sin(angle), 0.0);
-		mChangeDirectionInterval = rand() % 3000 + 1000;
-	}
-	mChangeDirectionInterval -= 1;
-
-	mPosition += mDirection * mSpeed;
-
-	real angle = mDirection.ToVec2().GetAngle();
-	mBodySpriteAnimator.SetAngle(angle);
-	mLegsSpriteAnimator.SetAngle(angle);
-
-	PhysicNode::Render();
-	//mLegsSpriteAnimator.Render();
-	mBodySpriteAnimator.Render();
-
-	//Renderer* r = GetDevice()->GetRenderer();
-	//Crown::Rectangle* rect = static_cast<Crown::Rectangle*>(GetShape());
-	//
-	//Vec2 min = rect->GetVertext(0) - mPosition.ToVec2();
-	//Vec2 size = rect->GetSize();
-	//if (mIsColliding)
-	//{
-	//	r->DrawRectangle(Point2(min.x, min.y), Point2(size.x, size.y), DM_BORDER, Color4::BLUE, Color4::BLUE);
-	//}
-	//else
-	//{
-	//	r->DrawRectangle(Point2(min.x, min.y), Point2(size.x, size.y), DM_BORDER);
-	//}
-	//mIsColliding = false;
-}
-

+ 0 - 30
samples/chainsawbuffet/entities/Zombie.h

@@ -1,30 +0,0 @@
-#ifndef __ZOMBIE_H__
-#define __ZOMBIE_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class Zombie: public PhysicNode
-{
-public:
-	Zombie(Scene* scene, Camera* camera);
-	virtual ~Zombie();
-
-	virtual void Update(real dt);
-	virtual void Render();
-
-	virtual void Collision(PhysicNode* other);
-
-private:
-	Auto<Sprite> mBodySprite;
-	Auto<Sprite> mLegsSprite;
-	SpriteAnimator mBodySpriteAnimator;
-	SpriteAnimator mLegsSpriteAnimator;
-	Vec3 mDirection;
-	real mSpeed;
-	int mChangeDirectionInterval;
-	bool mIsColliding;
-};
-
-#endif //__ZOMBIE_H__

+ 0 - 149
samples/chainsawbuffet/maain.cpp

@@ -1,149 +0,0 @@
-#include "TestApp.h"
-#include "ArenaScene.h"
-
-using namespace Crown;
-
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-//BEGIN_INCLUDE(all)
-#include <jni.h>
-#include <errno.h>
-
-#include <EGL/egl.h>
-#include <GLES/gl.h>
-
-#include <android/sensor.h>
-#include <android/log.h>
-#include <android_native_app_glue.h>
-
-#include "Crown.h"
-using namespace Crown;
-
-#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
-#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
-
-static void foobar()
-{
-	ArenaScene* arena = new ArenaScene(800, 480);
-	GetDevice()->GetSceneManager()->SelectNextScene(arena);
-}
-
-/**
- * Process the next main command.
- */
-static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
-    switch (cmd) {
-        case APP_CMD_SAVE_STATE:
-            // The system has asked us to save our current state.  Do so.
-            break;
-        case APP_CMD_INIT_WINDOW:
-            // The window is being shown, get it ready.
-			GetDevice()->Init(480, 800, 32, true);
-			foobar();
-            break;
-        case APP_CMD_TERM_WINDOW:
-            // The window is being hidden or closed, clean it up.
-			GetDevice()->StopRunning();
-			GetDevice()->Shutdown();
-            break;
-        case APP_CMD_GAINED_FOCUS:
-            // When our app gains focus, we start monitoring the accelerometer.
-            GetDevice()->StartRunning();
-            break;
-        case APP_CMD_LOST_FOCUS:
-            // When our app loses focus, we stop monitoring the accelerometer.
-            // This is to avoid consuming battery while not being used.
-			GetDevice()->StopRunning();
-            // Also stop animating.
-            break;
-    }
-}
-
-/**
- * This is the main entry point of a native application that is using
- * android_native_app_glue.  It runs in its own thread, with its own
- * event loop for receiving input events and doing other things.
- */
-void android_main(struct android_app* state) {
-
-    // Make sure glue isn't stripped.
-    app_dummy();
-
-	LOGI("Entrato in android_main!!!");
-	GetDevice()->_InitAndroidApp(state);
-
-    state->userData = NULL;
-    state->onAppCmd = NULL; // Manual cmd handling
-    state->onInputEvent = NULL; // Manual input handling
-
-    // loop waiting for stuff to do.
-
-    while (1) {
-
-        int ident;
-        int events;
-        struct android_poll_source* source;
-		struct android_app* app = state;
-
-{ //////////////////////////////////////
-        if ((ident=ALooper_pollOnce(0, NULL, &events,
-                (void**)&source)) >= 0) {
-					if (source != NULL)
-					{
-					if (source->id == LOOPER_ID_MAIN)
-					{
-						//LOGI("Entrato in LOOPER_ID_MAIN");
-						int8_t cmd = android_app_read_cmd(app);
-						android_app_pre_exec_cmd(app, cmd);
-						engine_handle_cmd(app, cmd);
-						android_app_post_exec_cmd(app, cmd);
-						//LOGI("Uscito da LOOPER_ID_MAIN");
-					}
-					}
-					//LOGI("Uscito da source != NULL");
-		}
-
-} ///////////////////////////////////
-
-        // Check if we are exiting.
-        if (state->destroyRequested != 0) {
-            exit(0);
-        }
-
-        // Drawing is throttled to the screen update rate, so there
-        // is no need to do timing here.
-		if (GetDevice()->IsInit())
-		{
-			if (GetDevice()->IsRunning())
-			{
-				GetDevice()->GetInputManager()->GetTouch()->EventLoop();
-				GetDevice()->GetRenderer()->_BeginFrame();
-				GetDevice()->GetSceneManager()->UpdateScene(0.02);
-				GetDevice()->GetSceneManager()->RenderScene();
-				GetDevice()->GetRenderer()->_EndFrame();
-				GetDevice()->GetMainWindow()->Update();
-			}
-		}
-    }
-
-	Log::D("Crown: bye bye.");
-}
-//END_INCLUDE(all)
-
-
-

+ 0 - 57
samples/chainsawbuffet/main.cpp

@@ -1,57 +0,0 @@
-#include "ArenaScene.h"
-
-using namespace Crown;
-
-class WndCtrl: public KeyboardListener
-{
-public:
-
-	WndCtrl()
-	{
-		GetDevice()->GetInputManager()->RegisterKeyboardListener(this);
-	}
-
-	virtual void KeyReleased(const KeyboardEvent& event)
-	{
-		if (event.key == KC_ESCAPE)
-		{
-			GetDevice()->StopRunning();
-		}
-	}
-};
-
-int main(int argc, char** argv)
-{
-	int wndW = 800;
-	int wndH = 480;
-
-	if (argc == 3)
-	{
-		wndW = atoi(argv[1]);
-		wndH = atoi(argv[2]);
-	}
-
-	Device* mDevice = GetDevice();
-
-	if (!mDevice->Init(wndW, wndH, 32, false))
-	{
-		return 0;
-	}
-
-	WndCtrl ctrl;
-
-	ArenaScene* mainScene = new ArenaScene(wndW, wndH);
-	GetDevice()->GetSceneManager()->SelectNextScene(mainScene);
-
-	mDevice->GetMainWindow()->SetTitle("Crown Engine v0.1 - Chainsaw Buffet");
-
-	while (mDevice->IsRunning())
-	{
-		mDevice->Frame();
-	}
-
-	mDevice->Shutdown();
-
-	return 0;
-}
-

+ 0 - 80
samples/chainsawbuffet/scenes/ArenaScene.cpp

@@ -1,80 +0,0 @@
-#include "ArenaScene.h"
-#include "Globals.h"
-
-ArenaScene::ArenaScene(Crown::uint windowWidth, Crown::uint windowHeight) :
-	mPg(NULL), mJoystick(NULL), mParticleManager(NULL)
-{
-}
-
-ArenaScene::~ArenaScene()
-{
-	if (mPg)
-	{
-		delete mPg;
-	}
-	for(int i = 0; i < mZombies.GetSize(); i++)
-	{
-		delete mZombies[i];
-	}
-	for(int i = 0; i < mWalls.GetSize(); i++)
-	{
-		delete mWalls[i];
-	}
-	for(int i = 0; i < mBackgrounds.GetSize(); i++)
-	{
-		delete mBackgrounds[i];
-	}
-	if (mJoystick)
-	{
-		delete mJoystick;
-	}
-	if (mParticleManager)
-	{
-		delete mParticleManager;
-	}
-}
-
-void ArenaScene::OnLoad()
-{
-	Scene::OnLoad();
-
-	Renderer* renderer = GetDevice()->GetRenderer();
-	renderer->SetClearColor(Color4(0.6f, 0.6f, 0.6f, 1.0f));
-	renderer->_SetLighting(false);
-
-	//Initialize the collision groups. The nodes will insert themselves in the correct group
-	GetPhysicsManager()->AddGroupPairCollisionCheck(CG_ZOMBIE, CG_ZOMBIE);
-	GetPhysicsManager()->AddGroupPairCollisionCheck(CG_ZOMBIE, CG_WALL);
-	GetPhysicsManager()->AddGroupPairCollisionCheck(CG_PG, CG_ZOMBIE);
-	GetPhysicsManager()->AddGroupPairCollisionCheck(CG_PG, CG_WALL);
-	GetPhysicsManager()->AddGroupPairCollisionCheck(CG_BULLET, CG_ZOMBIE);
-	GetPhysicsManager()->AddGroupPairCollisionCheck(CG_BULLET, CG_WALL);
-	
-	mMainCamera = this->AddCamera(NULL, Vec3(400.0, 240.0, 240.0), Angles::ZERO, true, 90, 800.0/480.0, true);
-
-	mBackgrounds.Append(new Background(this, mMainCamera,   0, 0));
-	mBackgrounds.Append(new Background(this, mMainCamera, 256, 0));
-	mBackgrounds.Append(new Background(this, mMainCamera, 512, 0));
-	mBackgrounds.Append(new Background(this, mMainCamera, 768, 0));
-
-	mBackgrounds.Append(new Background(this, mMainCamera,   0, 256));
-	mBackgrounds.Append(new Background(this, mMainCamera, 256, 256));
-	mBackgrounds.Append(new Background(this, mMainCamera, 512, 256));
-	mBackgrounds.Append(new Background(this, mMainCamera, 768, 256));
-
-	mPg = new Pg(this, mMainCamera);
-	for(int i = 0; i < 50; i++)
-	{
-		mZombies.Append(new Zombie(this, mMainCamera));
-	}
-	mWalls.Append(new Wall(this, mMainCamera, 300, 300, 100, 100));
-	mParticleManager = new ParticleManager(this, mMainCamera);
-	mJoystick = new Joystick(this, mMainCamera);
-}
-
-void ArenaScene::RenderScene()
-{
-	Scene::RenderScene();
-}
-
-

+ 0 - 38
samples/chainsawbuffet/scenes/ArenaScene.h

@@ -1,38 +0,0 @@
-#ifndef __ARENA_SCENE_H__
-#define __ARENA_SCENE_H__
-
-#include "Pg.h"
-#include "Zombie.h"
-#include "Joystick.h"
-#include "Wall.h"
-#include "Background.h"
-
-using namespace Crown;
-
-class ArenaScene: public Scene
-{
-public:
-	ArenaScene(Crown::uint windowWidth, Crown::uint windowHeight);
-	virtual ~ArenaScene();
-
-	virtual void OnLoad();
-	
-	virtual void RenderScene();
-
-	inline Camera* GetMainCamera() const
-	 { return mMainCamera; }
-
-	inline ParticleManager* GetParticleManager() const
-	 { return mParticleManager; }
-
-private:
-	Camera* mMainCamera;
-	Pg* mPg;
-	List<Zombie*> mZombies;
-	List<Wall*> mWalls;
-	List<Background*> mBackgrounds;
-	Joystick* mJoystick;
-	ParticleManager* mParticleManager;
-}; 
-
-#endif //__ARENA_SCENE_H__