Jump to content
  • Advertisement
Sign in to follow this  
NGEVA

bool error and only reading one of two id in list (using glpng) FIXED

This topic is 3318 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am not sure what to do with this... I have two images, one under background and one under character. the images are loaded into each but when being read, somehow they both have the same id even though i had separated them into their own objects.. actually, the id is not necessarily the second one because the information released is correct, but the id number when displayed still shows wrong just like the visual shown... i'm not sure what's wrong.. i have a boolean to keep track if the image is animated or a still image but somehow it resets to 204 during the setup phase but then in the rendering process, it is set to false.. and in doing so, the images are both sent to drawStill() instead of drawAnim() right now i think there might be something wrong with the listed classes especially rendering or imgloader classes but i cannot locate it.. =================================================================== [Edited by - NGEVA on May 22, 2009 2:14:03 AM]

Share this post


Link to post
Share on other sites
Advertisement
perhaps i analyzed the problem type a bit wrong and should have put this into [general programming]?...


EDIT: perhaps these might help?...

=====================================================
leading_node
#ifndef	LEADNODE_H
#define LEADNODE_H

#include "node.h"
#include "visualNode.h"

#include "AreaGraphics.h"
#include "linkedList.h"
//#include "camera.h"
#include "Rendering.h"

//class AreaGraphics;
//class rendering;
#ifdef LEADNODE_H
#define EXTERNA extern
#else
#define EXTERNA
#endif


EXTERNA linkedList<visualNode> render_root;
class leading_node : public node
{
public:
leading_node();
//virtual void addChild(visualNode c);
void linkup(visualNode *c);
void linkup(AreaGraphics *a);//(void));
void linkup(linkedList<visualNode> vis);
// void setCurentCamera(camera *a);
private:
};

#endif

#ifndef LEADNODE
#define LEADNODE

#include "leading_node.h"
//#include "Rendering.h"

#include <iostream>
using namespace std;


/*
virtual void leading_node::addChild(visualNode c)
{
base.addChild(c);
}*/


leading_node::leading_node()
{
}

void leading_node::linkup(visualNode *c)
{
//rendering().
render_root.insNext(c);
}

void leading_node::linkup(AreaGraphics *a)// (*)(void))
{
AreaGraphics b = *a;

cout<<"linking area to render_root"<<endl;
render_root.insNext(b.getList());
}

//void leading_node::setCurentCamera(camera *a)
/*{
// cam = a;
}*/


#endif

=====================================================
area_graphics (i should name this graphics translation or something...)
/*

manipulates the visibility of items within the area passed to it

then the data is read by leading node externally

*/


#ifndef AREAGRAPHICS_H
#define AREAGRAPHICS_H

//#include "Rendering.h"
#include "area.h"
#include "node.h"
//#include "leading_node.h"
#include "linkedList.h"
#include "visualNode.h"

//class area;

class AreaGraphics : public node
{
public:
AreaGraphics();
AreaGraphics(area *a);
//void draw(node *background, node *character, node *object);

linkedList<visualNode> *getList();
void scanBackgrounds();
void scanCharacters();
private:
//_level *current;
area *_area;

linkedList<visualNode> finalList;
};

//==============================================================



#endif


#include "AreaGraphics.h"

#include <iostream>
using namespace std;

AreaGraphics::AreaGraphics()
{
}

linkedList<visualNode> *AreaGraphics::getList()
{
return &finalList;
}

AreaGraphics::AreaGraphics(area *a)
{
_area = a;

scanBackgrounds();

cout<<"finalList has "<<finalList.totalItems()<<" items"<<endl;
scanCharacters();
cout<<"finalList has "<<finalList.totalItems()<<" items"<<endl;

}

void AreaGraphics::scanBackgrounds()
{

if(_area->bkgd.currentEmpty())
return;

do{
if( _area->bkgd.getCurrentData()->getVisibility() )
{
finalList.insTail(&_area->bkgd.current->data);//getCurrentData());
cout<<"added ";_area->bkgd.current->data.showFilename();
cout<<" to finalList"<<endl<<" ";
_area->bkgd.current->data.show_pngInfo_dump();//cout<<endl;
}

if(_area->bkgd.retNext())
_area->bkgd.moveFwd();
else
break;
}while(true);

}

void AreaGraphics::scanCharacters()
{

if(_area->chr.currentEmpty())
return;

do{
if( _area->chr.getCurrentData()->getVisibility() )
{
finalList.insTail(&_area->chr.current->data);//getCurrentData());
cout<<"added ";_area->chr.current->data.showFilename();cout<<
" to finalList"<<endl<<" ";
_area->chr.current->data.show_pngInfo_dump();//cout<<endl;
}

if(_area->chr.retNext())
_area->chr.moveFwd();
else
break;
}while(true);

}





=====================================================
area
#ifndef AREA_H
#define AREA_H

//#include "AreaGraphics.h" //friend

#include "background.h"
#include "object.h"
#include "character.h"

#include "node.h"

#include "linkedList.h"

class AreaGraphics;

typedef linkedList<background> backgrounds;
typedef linkedList<character> characters;

class area: public node
{
friend class AreaGraphics;
public:
area();
void addBkgd(char *filename);
// addObject();
void addChr(char *filename);
int getAreaID();
void setID(int num);
character getCharacter(int character_num);
private:
int area_id;
backgrounds bkgd;
characters chr;
int totalCharacters;
// linkedList<object> obj;
// linkedList<character> ch;
};
#endif

#include "area.h"

#include <iostream>
using namespace std;

int area::getAreaID()
{
return area_id;
}

area::area()
{
totalCharacters=0;
}

void area::addBkgd(char *filename)
{
cout<<"running addBkgd"<<endl;
cout<<"bkgd.currentEmpty() = "<<bkgd.currentEmpty()<<endl;
if(!bkgd.currentEmpty())
return;

background *temp;
background tempa;
cout<<"loading file: "<<filename<<endl;
cout<<"current file loaded: ";tempa.showFilename();
tempa.load(filename);
cout<<"current file loaded: ";tempa.showFilename();
tempa.setVisible();
temp = &tempa;

bkgd.insNext(&tempa);
}

character area::getCharacter(int character_num)
{
character emptyTemp;
if(chr.current==0)//Empty())
return emptyTemp;//0;//!chr.currentEmpty();

chr.current = chr.head;

while(chr.current->data.getCharacterID()!=character_num)
{
if(chr.retNext() == 0)
return emptyTemp;//0;

chr.moveFwd();
}

return chr.current->data;
}

void area::addChr(char *filename)
{
cout<<"running addChr"<<endl;
cout<<"chr.currentEmpty() = "<<chr.currentEmpty()<<endl;
//if(!chr.currentEmpty())
// return;



character tempa;
cout<<"loading file: "<<filename<<endl;
cout<<"current file loaded: ";tempa.showFilename();
tempa.load(filename);
cout<<"current file loaded: ";tempa.showFilename();
tempa.setVisible();
// temp = &tempa;

chr.insNext(&tempa);
// chr.moveFwd();
chr.current->data.addCharacter();
totalCharacters++;
}

void area::setID(int num)
{
area_id = num;
}

=====================================================
level

//#include "Rendering.h"
#include "area.h"
#include "node.h"
//#include "background.h"
#include "linkedList.h"

//friend class _AreaGraphics();

class _level: public node
{
public:
_level();
void addArea();
void addBackground(char *filename, int area_num);
void addCharacter(char *filename, int area_num);//, int character_num);
linkedList<area> getArea();
area getArea(int area_num);
void getCurrentArea(int area_num);

area currentArea;
// addObject();
// addCharacter();
private:
/*
character;
object;*/

// background;

int totalAreas;

linkedList<area> _area;

};


#include "Level.h"

_level::_level()
{
totalAreas=0;
}

linkedList<area> _level::getArea()
{
return _area;
}

void _level::getCurrentArea(int area_num)
{
currentArea = getArea(area_num);
}

area _level::getArea(int area_num)
{
area emptyTemp;
if(_area.current==0)//Empty())
return emptyTemp;//0;

_area.current = _area.head;

while(_area.current->data.getAreaID()!=area_num)
{
if(_area.retNext() == 0)
return emptyTemp;//0;

_area.moveFwd();
}

return _area.current->data;
}

void _level::addArea()
{
totalAreas++;

area *temp;
area tempa;
tempa.setID(totalAreas);
temp = &tempa;
//temp->setID(totalAreas);

_area.insNext(temp);
}

void _level::addBackground(char *filename, int area_num)
{
_area.current=_area.retFirst();

while(_area.current->data.getAreaID()!=area_num)
{
if(!_area.retNext())
return;

_area.moveFwd();
}

_area.current->data.addBkgd(filename);
}

void _level::addCharacter(char *filename, int area_num)//, int character_num)
{
_area.current=_area.retFirst();

while(_area.current->data.getAreaID()!=area_num)
{
if(!_area.retNext())
return;

_area.moveFwd();
}

_area.current->data.addChr(filename);
}



[Edited by - NGEVA on May 20, 2009 9:05:50 PM]

Share this post


Link to post
Share on other sites
so 204 = 0001 1110
i guess that makes sense for why the value is also zero but then it is still weird... the currently animated debug line is also within the imgLoader just like the show all info function.... why does it khasve a difference between 204 and 0?... but also,m as two separate objects, i don't get why they seem o have overwritten values.. and the setting of isAnimated to 0 or 1 don't really seem to affect anything... i was able to fill in the frame values during the run but it won't be displayed properly because it will see it as 0 (or, not animated) and then proceed with the drawStill() function....



new console debugging output
========================================
running addBkgd
bkgd.currentEmpty() = 1
loading file: test_background.png
current file loaded:
pre load
post load
Size=640,480 Depth=8 Alpha=0
current item has the following id: 1
isAnimated currently is: 204
isAnimated currently is: 0
current file loaded: test_background.png
========================================
running addChr
chr.currentEmpty() = 1
loading file: SuperSonic1.png
current file loaded:
pre load
post load
Size=287,98 Depth=16 Alpha=8
current item has the following id: 2
isAnimated currently is: 204
isAnimated currently is: 0
current file loaded: SuperSonic1.png
isAnimated currently is: 204
isAnimated currently is: 1
========================================
added test_background.png
to finalList
Size=640,480 Depth=8 Alpha=0
finalList has 1 items
=============================================================================
Show All Info
_filename : test_background.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 640 | height : 480
Size=640,480 Depth=8 Alpha=0
=============================================================================
added SuperSonic1.png
to finalList
Size=287,98 Depth=16 Alpha=8
finalList has 2 items
=============================================================================
Show All Info
_filename : test_background.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 640 | height : 480
Size=640,480 Depth=8 Alpha=0
=============================================================================
=============================================================================
Show All Info
_filename : SuperSonic1.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 287 | height : 98
Size=287,98 Depth=16 Alpha=8
=============================================================================
linking area to render_root
=============================================================================
Show All Info
_filename : test_background.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 640 | height : 480
Size=640,480 Depth=8 Alpha=0
=============================================================================
=============================================================================
Show All Info
_filename : SuperSonic1.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 287 | height : 98
Size=287,98 Depth=16 Alpha=8
=============================================================================
linking now in progress.
linked
=========================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
Press any key to continue . . .






the issue was in how i setup the character versus how i setup the area. with the area i had setID but the characers had a different sort of thing which in reality should have been the same and when i reverted the function to look like the setID for add area, the 204 reappearance problem disappeared

===================================================================
updated debug code. the 204 reappearance issue is removed. the end resultant value for isAnimated is still sitting at 0 though and the id problem remains as well
========================================
running addBkgd
bkgd.currentEmpty() = 1
loading file: test_background.png
current file loaded:
pre load
post load
Size=640,480 Depth=8 Alpha=0
current item has the following id: 1
isAnimated currently is: 204
isAnimated currently is: 0
current file loaded: test_background.png
========================================
running addChr
chr.currentEmpty() = 1
loading file: SuperSonic1.png
current file loaded:
pre load
post load
Size=287,98 Depth=16 Alpha=8
current item has the following id: 2
isAnimated currently is: 204
isAnimated currently is: 0
current file loaded: SuperSonic1.png
isAnimated currently is: 0
isAnimated currently is: 1
========================================
added test_background.png
to finalList
Size=640,480 Depth=8 Alpha=0
finalList has 1 items
=============================================================================
Show All Info
_filename : test_background.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 640 | height : 480
Size=640,480 Depth=8 Alpha=0
=============================================================================
added SuperSonic1.png
to finalList
Size=287,98 Depth=16 Alpha=8
finalList has 2 items
=============================================================================
Show All Info
_filename : test_background.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 640 | height : 480
Size=640,480 Depth=8 Alpha=0
=============================================================================
=============================================================================
Show All Info
_filename : SuperSonic1.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 287 | height : 98
Size=287,98 Depth=16 Alpha=8
=============================================================================
linking area to render_root
=============================================================================
Show All Info
_filename : test_background.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 640 | height : 480
Size=640,480 Depth=8 Alpha=0
=============================================================================
=============================================================================
Show All Info
_filename : SuperSonic1.png | filename : <POINTER> | isVisible : 1
isAnimated : 0 | id : 2 | imgID : 2
width : 287 | height : 98
Size=287,98 Depth=16 Alpha=8
=============================================================================
linking now in progress.
linked
=========================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
render_root is not empty
render_root has 2 items linked.
=================================================================
Size=640,480 Depth=8 Alpha=0

rendering item: test_background.png
test_background.png's animation status is: 0
current item has id: 2running drawStill()
test_background.png
===========================================================
Size=287,98 Depth=16 Alpha=8

rendering item: SuperSonic1.png
SuperSonic1.png's animation status is: 0
current item has id: 2running drawStill()
SuperSonic1.png
===========================================================
Press any key to continue . . .



===========================================================
i fixed the isAnimated issue when i attempted to revert my get functions into pointer based referencing. all that remains is the id matter.... during the loading it overwrites the id.. even the individual id gets overwritten... not sure why...

[Edited by - NGEVA on May 21, 2009 6:35:51 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!