Permalink
Browse files

convert everything to grrlib, compiling fine

  • Loading branch information...
1 parent 5512bdf commit 91178db5915f2718efd5c912c7011cf7760171d7 @PowerKiKi committed Oct 21, 2010
View
@@ -22,10 +22,10 @@ include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
TARGET := ../polukili/boot
BUILD := build
-SOURCES := source source/Bullets source/Ennemies source/Items source/Pets source/Players lib/box2d/Source/Collision lib/box2d/Source/Collision/Shapes lib/box2d/Source/Common lib/box2d/Source/Dynamics lib/box2d/Source/Dynamics/Contacts lib/box2d/Source/Dynamics/Controllers lib/box2d/Source/Dynamics/Joints lib/libwiisprite/source
-DATA :=
+SOURCES := source source/Bullets source/Ennemies source/Items source/Pets source/Players lib/box2d/Box2D/Collision lib/box2d/Box2D/Collision/Shapes lib/box2d/Box2D/Common lib/box2d/Box2D/Dynamics lib/box2d/Box2D/Dynamics/Contacts lib/box2d/Box2D/Dynamics/Joints lib/libwiisprite/source
+DATA := data
TEXTURES := textures
-INCLUDES := source lib/box2d/Include lib/libwiisprite/source
+INCLUDES := source lib/box2d lib/libwiisprite/source
#---------------------------------------------------------------------------------
# options for code generation
@@ -39,7 +39,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
-LIBS := -lpng -lz -lfat -lmxml -lwiiuse -lbte -logc -lm
+LIBS := -lgrrlib -lfreetype -lpngu -lpng -ljpeg -lz -lfat -lmxml -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@@ -128,6 +128,14 @@ $(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
+# This rule links in binary data with the .ttf extension
+#---------------------------------------------------------------------------------
+%.ttf.o : %.ttf
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ $(bin2o)
+
+#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
#---------------------------------------------------------------------------------
%.bin.o : %.bin
Binary file not shown.
Oops, something went wrong.
@@ -4,7 +4,7 @@
#include <Console.h>
#include <Game.h>
#include <Level.h>
-
+#include <Sprite.h>
namespace Polukili
{
@@ -41,24 +41,27 @@ namespace Polukili
}
/*************************************************/
- void Actor::initPhysic(const b2Vec2& position)
+ void Actor::initPhysic(const b2Vec2& position, float32 angle)
{
this->timer.start();
b2BodyDef bodyDef;
basePosition = position;
bodyDef.position = position;
- this->body = level->world->CreateBody(&bodyDef);
+ bodyDef.angle = angle;
+ bodyDef.type = b2_dynamicBody;
+ Console::log(LOG_INFO, "positon is: %f, %f", position.x, position.y);
+ this->body = this->level->world->CreateBody(&bodyDef);
this->body->SetUserData(this);
}
/*************************************************/
void Actor::render()
{
- this->sprite->SetZoom(this->powerFactor);
- this->sprite->SetRotation((float)this->body->GetAngle() / M_PI * 90.0);
- b2Vec2 pos = body->GetPosition();
- this->sprite->SetPosition(Constants::pixelsPerUnits * pos.x, Constants::pixelsPerUnits * pos.y);
- this->sprite->Draw();
+ this->sprite->setZoom(this->powerFactor);
+ this->sprite->setRotation((float)this->body->GetAngle() / M_PI * 90.0);
+ b2Vec2 pos = this->body->GetPosition();
+ this->sprite->setPosition(Constants::pixelsPerUnits * pos.x, Constants::pixelsPerUnits * pos.y);
+ this->sprite->draw();
}
/*************************************************/
@@ -70,11 +73,10 @@ namespace Polukili
/*************************************************/
void Actor::loadGraphics()
{
- wsp::Image* image = this->level->game->imageLibrary.get(this->getImagePath());
- this->sprite = new wsp::Sprite();
- this->sprite->SetImage(image, this->getImageWidth(), this->getImageHeight());
- this->sprite->SetRefPixelPositioning(wsp::REFPIXEL_POS_PIXEL);
- this->sprite->SetRefPixelPosition(((int)this->getImageWidth()/2),(int)(this->getImageHeight()/2));
+ GRRLIB_texImg* image = this->level->game->imageLibrary.get(this->getImagePath());
+ this->sprite = new Sprite(image, this->getImageWidth(), this->getImageHeight());
+ // this->sprite->SetRefPixelPositioning(wsp::REFPIXEL_POS_PIXEL);
+ // this->sprite->SetRefPixelPosition(((int)this->getImageWidth()/2),(int)(this->getImageHeight()/2));
}
/*************************************************/
View
@@ -3,9 +3,8 @@
#include <string>
-#include <wiisprite.h>
#include <mxml.h>
-#include <Box2D.h>
+#include <Box2D/Box2D.h>
#include <Effect.h>
#include <Element.h>
@@ -44,7 +43,7 @@ namespace Polukili
virtual void render();
/**
- * Load graphics data (wsp::Image) for the actor. In most cases the same Image will be loaded once for all instance of a specific class.
+ * Load graphics data (GRRLIB_texImg) for the actor. In most cases the same Image will be loaded once for all instance of a specific class.
*/
virtual void loadGraphics();
@@ -64,17 +63,17 @@ namespace Polukili
virtual void nextStep();
/**
- * Returns if the actor accept annother actor to be dropped on itself.
+ * Returns if the actor accept another actor to be dropped on itself.
*/
virtual bool acceptDrop(Actor &actorToBeDropped);
/**
- * Returns wether the actor is weak against the specified element.
+ * Returns whether the actor is weak against the specified element.
*/
virtual bool isWeak(Element element);
/**
- * Returns wether the actor is strong against the specified element.
+ * Returns whether the actor is strong against the specified element.
*/
virtual bool isStrong(Element element);
@@ -91,7 +90,7 @@ namespace Polukili
/**
* Initialize physic data
*/
- virtual void initPhysic(const b2Vec2& position);
+ virtual void initPhysic(const b2Vec2& position, float32 angle = 0);
/**
* Returns the path to the image for the sprite.
@@ -143,7 +142,7 @@ namespace Polukili
/**
* The graphical sprite.
*/
- wsp::Sprite* sprite;
+ Sprite* sprite;
/**
* Current state of the actor. It may be several state at once (flags).
@@ -1,49 +0,0 @@
-/*
-
- BibScreenFont.cpp
-
-*/
-
-#include <wiisprite.h>
-#include <Console.h>
-#include "BibScreenFont.h"
-
-
-void BibScreenFont::Initialize (wsp::Image * pImage, int innXLetterWidth, int innYLetterHeight,
- const unsigned char * innCharWidths)
-{
- nXLetterWidth = innXLetterWidth;
- nYLetterHeight = innYLetterHeight;
- nCharWidths = innCharWidths;
- AlphabetBitmap.SetImage (pImage, nXLetterWidth, nYLetterHeight);
-}
-
-/*
- Transparency has a range from 0x00 (invisible) to 0xFF (fully visible)
-*/
-void BibScreenFont::DisplayText (int nXScreenLoc, int nYScreenLoc, const char * szText, int nTransparency)
-{
- // Loop for every character.
- for (int i = 0; szText [i]; i++)
- {
- char cChar = szText [i];
- if (cChar >= 128)
- cChar &= 0xEF;
-
- // Render each letter.
- AlphabetBitmap.SetPosition(nXScreenLoc, nYScreenLoc);
- AlphabetBitmap.SetFrame(cChar);
- AlphabetBitmap.SetTransparency (nTransparency);
- AlphabetBitmap.Draw();
-
- // Every time we blit a letter we need to move to the right
- // for the start of the next blit
- nXScreenLoc += nCharWidths[(int)cChar];
- }
-}
-
-/*************************************************/
-int BibScreenFont::getCharacterHeight() const
-{
- return nYLetterHeight;
-}
@@ -1,53 +0,0 @@
-/*
-
- BibScreenFont.h
-
-
- This class was designed around two ideas.
- 1. It uses LibWiiSprite for screen drawing details and assumes the
- correct header file <wiisprite.h> is in place as well as the library.
- 2. It was designed to work with output of F2IBuilder ( http://sourceforge.net/projects/f2ibuilder/ ).
-
-
- F2IBuilder can output two files, a PNG and a Metrics file.
- This class expects the two files to be run through raw2c.exe (from DevKitPro)
- and included(.h) and compiled(.c) into the project.
- The png data should be loaded into a wsp Image class via LoadImage.
- The metrics data should be passed directly as the nCharWidths parameter to Initialize.
-
-
- Initialize() should be called first and only once.
- DisplayText() should be called to display text for the current frame.
-
-*/
-
-
-#ifndef _BIBSCREENFONT_H_
-#define _BIBSCREENFONT_H_
-
-#include <wiisprite.h>
-
-class BibScreenFont
-{
-private:
- wsp::Sprite AlphabetBitmap;
- int nXLetterWidth;
- int nYLetterHeight;
- const unsigned char * nCharWidths; // Array of [128]
- int nCharsPerLine;
-
-public:
-
- void Initialize (wsp::Image * pImage, int nXLetterWidth, int nYLetterHeight,
- const unsigned char * nCharWidths);
- void DisplayText(int nXScreenLoc, int nYScreenLoc, const char * szText, int nTransparency = 0xFF);
-
- /**
- * Returns the height in pixels of a character.
- */
- int getCharacterHeight() const;
-
-
-};
-#endif
-
@@ -23,23 +23,25 @@ namespace Polukili
}
/*************************************************/
- void Bullet::initPhysic(const b2Vec2& position, float angle)
+ void Bullet::initPhysic(const b2Vec2& position, float32 angle)
{
- this->Actor::initPhysic(position);
- b2PolygonDef bulletShape;
+ this->Actor::initPhysic(position, angle);
+ b2PolygonShape bulletShape;
bulletShape.SetAsBox(((float)this->getImageWidth() * this->powerFactor / Constants::pixelsPerUnits) / 2.0f, ((float)this->getImageHeight() * this->powerFactor / Constants::pixelsPerUnits) / 2.0f);
- bulletShape.density = Constants::defaultDensity;
- bulletShape.friction = Constants::defaultFriction;
- bulletShape.restitution = Constants::defaultRestitution;
- bulletShape.filter.categoryBits = bullets;
- bulletShape.filter.maskBits = ground+enemies;
- this->body->CreateFixture(&bulletShape);
- this->body->SetMassFromShapes();
- this->body->SetAngle(angle);
+
+ b2FixtureDef bulletDef;
+ bulletDef.shape = &bulletShape;
+ bulletDef.density = Constants::defaultDensity;
+ bulletDef.friction = Constants::defaultFriction;
+ bulletDef.restitution = Constants::defaultRestitution;
+ bulletDef.filter.categoryBits = bullets;
+ bulletDef.filter.maskBits = ground + enemies;
+ this->body->CreateFixture(&bulletDef);
+
b2Vec2 shotImpulse;
shotImpulse.x = 2*cos(angle);
shotImpulse.y = 2*sin(angle);
- this->body->ApplyImpulse(shotImpulse, this->body->GetPosition());
+ this->body->ApplyLinearImpulse(shotImpulse, this->body->GetPosition());
}
/*************************************************/
@@ -1,14 +1,9 @@
-/*
- Console class
-
- console (printf) support for libwiisprite
-*/
#include <Console.h>
#include <stdio.h>
#include <sys/iosupport.h>
#include <stdarg.h>
-#include <wiisprite.h>
+#include <grrlib.h>
#include <Constants.h>
@@ -23,7 +18,7 @@ namespace Polukili
static const int maximumColumns = 80;
static int cursor_row = 0;
static int cursor_col = 0;
- static char the_console[maximumRows][maximumColumns + 1];
+ static wchar_t the_console[maximumRows][maximumColumns + 1];
/*************************************************/
ssize_t Console_write(struct _reent* rUnused, int fdUnused, const char* ptr, size_t length)
@@ -69,7 +64,7 @@ namespace Polukili
}
/*************************************************/
- void Console::initialize(BibScreenFont* font)
+ void Console::initialize(GRRLIB_ttfFont* font)
{
this->font = font;
cursor_row = 0;
@@ -89,9 +84,11 @@ namespace Polukili
/*************************************************/
void Console::render()
{
+ unsigned int fontsize = 20;
for (int i = 0; i < maximumRows; i ++)
{
- this->font->DisplayText(16, 16 + i * this->font->getCharacterHeight(), the_console[i]);
+ GRRLIB_PrintfTTFW(16, 16 + i * fontsize,this->font, the_console[i], fontsize, RGBA(255,0,0,0));
+ //this->font->DisplayText(16, 16 + i * this->font->getCharacterHeight(), the_console[i]);
}
}
@@ -1,17 +1,18 @@
#ifndef Polukili_Console_h
#define Polukili_Console_h
-#include <BibScreenFont.h>
#include <fstream>
+#include <grrlib.h>
+
#define LOG_INFO __FILE__, __PRETTY_FUNCTION__, __LINE__
using namespace std;
namespace Polukili
{
/**
- * console (printf) support for libwiisprite
+ * Console (printf) support for libwiisprite
*/
class Console
{
@@ -30,7 +31,7 @@ namespace Polukili
static void log(const char* file, const char* function, int line, const string& input, ...);
static ssize_t write(const string&, const char* prefix = 0);
- void initialize(BibScreenFont* font);
+ void initialize(GRRLIB_ttfFont* font);
void render();
void clear();
@@ -41,14 +42,14 @@ namespace Polukili
void enable(bool enabled);
/**
- * Returns wether the console is enabled.
+ * Returns whether the console is enabled.
*/
bool isEnabled() const;
static fstream logFile;
private:
- BibScreenFont* font;
+ GRRLIB_ttfFont* font;
static bool enabled;
};
}
Oops, something went wrong.

0 comments on commit 91178db

Please sign in to comment.