So, did I make the unsolvable error? Or is there some answer? I just really wanna get this fixed, so i can continue to code ;)
and feel free to ask to see more code if that's needed! :)
Printable View
So, did I make the unsolvable error? Or is there some answer? I just really wanna get this fixed, so i can continue to code ;)
and feel free to ask to see more code if that's needed! :)
&plat.rect would actually be the address of plat.rect, so presumably Intersect takes a pointer to an hgeRect.
What I meant was, the file that has the function definitions you're trying to write (you know -- the one with the errors in it?) needs both header files included. You don't include a header file in itself.
You will have to provide more (any) details.
See, this is where some idea about the "design" of the program would come in, like who depends on what, and what services a class provides.
This "everything" includes everything else just ties you in knots of cyclic dependency with no way out.
well all Bazaar users can download my code easily by typing "bzr branch lp:mba" but I don't expect people to be that dedicated to help xP
https://code.launchpad.net/~ian.t.ja...loodshed_Arena That's the url to the project code launchpad site, and if someone uses some other SVN client than Bazaar, I guess it's possible to get the project, I just dunno how xP
But let me show you all the code that has something to do with this problem.
Code:#include "character.h"
#include "platform.h"
character::character(){
}
character::~character(){
}
void character::renderQuad(HGE* hge, hgeQuad* quad){
hge->Gfx_RenderQuad(quad);
}
void character::flipLeft(hgeQuad* quad){
quad->v[0].tx = 1.0f; quad->v[0].ty = 0.0f;
quad->v[1].tx = 0.0f; quad->v[1].ty = 0.0f;
quad->v[2].tx = 0.0f; quad->v[2].ty = 1.0f;
quad->v[3].tx = 1.0f; quad->v[3].ty = 1.0f;
}
void character::flipRight(hgeQuad* quad){
quad->v[0].tx = 0.0f; quad->v[0].ty = 0.0f;
quad->v[1].tx = 1.0f; quad->v[1].ty = 0.0f;
quad->v[2].tx = 1.0f; quad->v[2].ty = 1.0f;
quad->v[3].tx = 0.0f; quad->v[3].ty = 1.0f;
}
void character::updateQVert(hgeQuad* quad){
quad->v[0].x = x - 16; quad->v[0].y = y - 32;
quad->v[1].x = x + 16; quad->v[1].y = y - 32;
quad->v[2].x = x + 16; quad->v[2].y = y + 32;
quad->v[3].x = x - 16; quad->v[3].y = y + 32;
}
void character::pullDown(){
y += gravityPull;
dir = DOWN;
}
void character::stop(HGE* hge, character& c, platform& plat){
float dt = hge->Timer_GetDelta();
if(c.charRect.Intersect(&plat.rect)){
if(dir == LEFT) x += speed * dt;
if(dir == RIGHT) x -= speed * dt;
if(dir == DOWN) y -= gravityPull;
if(dir == UP) y += speed * dt;
}
}
Code:#include "worldManager.h"
worldManager::worldManager(HGE* h){
hge = h;
}
worldManager::~worldManager(){
}
void worldManager::gravity(character& c){
c.pullDown();
}
void worldManager::chrIntersectPlat(character& c, platform& plat){
c.stop(hge,c,plat);
}
Code:#ifndef WORLDMANAGER_H
#define WORLDMANAGER_H
//worldmanager.h
#include "character.h"
#include "platform.h"
class worldManager {
private:
HGE* hge;
public:
worldManager(HGE* h);
~worldManager();
void chrIntersectPlat(character& c, platform& plat);
void gravity(character& c);
};
That should be it...Code:#include "platform.h"
platform::platform(){
updateQVert();
updateRect();
//class quad texture setup
platQuad.v[0].tx = 0.0f; platQuad.v[0].ty = 0.0f;
platQuad.v[1].tx = 1.0f; platQuad.v[1].ty = 0.0f;
platQuad.v[2].tx = 1.0f; platQuad.v[2].ty = 1.0f;
platQuad.v[3].tx = 0.0f; platQuad.v[3].ty = 1.0f;
}
platform::~platform(){
}
void platform::updateQVert(){
platQuad.v[0].x = x; platQuad.v[0].y = y;
platQuad.v[1].x = x + 32; platQuad.v[1].y = y;
platQuad.v[2].x = x + 32; platQuad.v[2].y = y + 32;
platQuad.v[3].x = x; platQuad.v[3].y = y + 32;
}
void platform::quadTexture( HTEXTURE tex, DWORD col, int blend){
platQuad.tex = tex;
platQuad.blend = blend;
for(int i = 0; i < 4; i++){
platQuad.v[i].col=col;
platQuad.v[i].z=z;
}
}
void platform::quadRender(HGE* hge){
hge->Gfx_RenderQuad(&platQuad);
}
void platform::updateRect(){
rect.x1 = x; rect.y1 = y;
rect.x2 = x + 32; rect.y2 = y + 32;
}
void platform::move(float x2, float y2){
x = x2;
y = y2;
updateRect();
updateQVert();
}
Salem, what you talking about? xP
I know my code ain't professional and clean xP but most of it works ;)
Well, I cleaned the code up a load, and now it works ^^
I learnt something from it atleast ;) I must remember to try to keep the code as clean as possible ^^
That's the point of Salem's post: You should DESIGN your classes such that you understand what depends on what.
There are some different ways to come up with a design, many books and even more PhD thesis' have been written on the subject. But the basics of it is pretty simple:
1. Figure out what data and functions you need to have to solve a particular problem (or part of the problem).
2. Figure out how the different data items and functions interact.
3. Make up classes that contain data that belong together, and add functions that "make sense".
It is often best to try to be minimalist in class and function design - but of course, a class/function should add some value to the overall program - if it doesn't, then it's probably "too small".
[Of course, if you read a design class/book, you'll find that it takes 200-500 pages to describe the above, with many examples and a lot more detail - because you wouldn't be able to sell a book that is only half a page! ;) ].
--
Mats
Just hacking the code tops out at about 5K lines. Beyond that, adding new features takes more and more effort, and fixing bugs introduces bugs at an ever increasing rate (to the point every fix is a bug).
You've got the skill for the coding, but you need to develop other skills now to be able to build much larger programs.