strange "syntax error" problem :S

This is a discussion on strange "syntax error" problem :S within the C++ Programming forums, part of the General Programming Boards category; So, did I make the unsolvable error? Or is there some answer? I just really wanna get this fixed, so ...

  1. #16
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    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!
    Currently research OpenGL

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    &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.

  3. #18
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #19
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    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);
    
    };
    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();
    }
    That should be it...
    Currently research OpenGL

  5. #20
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Salem, what you talking about? xP
    I know my code ain't professional and clean xP but most of it works
    Currently research OpenGL

  6. #21
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    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 ^^
    Currently research OpenGL

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Akkernight View Post
    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
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #23
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by BMJ View Post
    Are you sure you mean "&plat.rect"? Since plat is passed as a reference "&plat" literally means "the address of plat"
    Actually, it means address of the element rect in plat, because . has higher order of precedence than & in this expression.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange problem with GETLINE
    By wco5002 in forum C++ Programming
    Replies: 13
    Last Post: 07-07-2008, 10:57 AM
  2. Strange problem
    By G4B3 in forum C Programming
    Replies: 6
    Last Post: 05-14-2008, 03:07 PM
  3. Strange problem with classes in header files
    By samGwilliam in forum C++ Programming
    Replies: 2
    Last Post: 02-29-2008, 04:55 AM
  4. Strange problem
    By ~Kyo~ in forum Game Programming
    Replies: 0
    Last Post: 02-14-2006, 10:35 PM
  5. Strange problem with fts_open call
    By jhopper in forum C Programming
    Replies: 0
    Last Post: 02-26-2002, 12:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21