Pandora Pandora Panic


Vorporeal said:
hells_dark said:
Why not start to use http://archive.openpandora.org ?



I think that's more for finished programs, drivers, things like that. This is, as of now, just a framework (that's still in the making) and some (semi-)completed mini-games. Probably not the kind of thing to go on the archive.

I don't know.. it would fit quite well here > Development tools.
It's sad to see the archive so empty :p
 
Last edited by a moderator:
hells_dark said:
Vorporeal said:
hells_dark said:
Why not start to use http://archive.openpandora.org ?



I think that's more for finished programs, drivers, things like that. This is, as of now, just a framework (that's still in the making) and some (semi-)completed mini-games. Probably not the kind of thing to go on the archive.

I don't know.. it would fit quite well here > Development tools.
It's sad to see the archive so empty :p

I like the suggestion. I think that once the framework actually compiles to a Pandora target, we can upload it! :)
Right now PP! is helping me find and fix bugs, and it's a little bit early to be uploading this to the archive.
 
Last edited by a moderator:
If anyone can spare a moment, I'd like a little pointer on pointers. :)

Simplified, I have this:

CODE

# In the header file
class OBBShape {
public:
string name;
Sprite &sprite;
void initShape(string n);
};

class StateOneButtonBandit : public BaseState {
public:
int numberOfShapes;
OBBShape *shapes[2];
};

# In the cpp file
void OBBShape::initShape(string n) {
name = n;
}

StateOneButtonBandit::StateOneButtonBandit() {
// Load up the array of shapes we get to play with
numberOfShapes = 1;
shapes[0]->initShape("square");
}



I need shapes to be an array of pointers to OBBShape objects (so I only need to load each sprite once and can reference each one as many times as needed without consuming vast amounts of memory or doing lots of in-memory copies) but I'm having a problem with the name = n line. The compiler tells me nothing, the program just crashes and burns when I attempt to load OneButtonBandit. I've tried doing things like this.name and this->name but I'm really just guessing. Any suggestions?

EDIT: I've worked this part out. Turns out I needed to do (having first defined a constructor and a destructor):
CODE

shapes[0] = new OBBShape;
shapes[0]->initShape("square");



Thinking in pointers is a quite difficult when you're coming from a language where everything is a pointer. :)

EDIT 2: If anyone else is struggling with pointers and references in C++ it seems to be because pointers are stupidheads that should go and play somewhere else. This is informative: http://www.informit.com/guides/content.asp...&seqNum=166
 
Glad you are getting along ok, even with all that fun pointer stuff! :p

Quick update:
I fixed the background transparency issue,
I have also implemented most of Kagatos GUI work now. So update due tomorrow :) But now, sleep!

Miggles: Please send me your latest Pong!
If anyone else has updated their games, please let me know about the latest versions, the main project should be kept up to date ;)
 
Ok update then: http://willhostforfood.com/?Action=PublicD...ry&u=100986

The zero issue is fixed, and there is a background tune. It still error's on exit sometimes though, even though i added the stopmusic code :S. could you take a look at that perhaps?

Also if you select the game (testing obviously) the first equation(english?) is always the same :S but that's less important.


Edit: updated is distractedmath 0.1.4 ;)
 
Pong! (Url is slightly different. I'm rather liking drop.io)

There are two things left I want to do with Pong:
  1. Change the bounce angle based on collision point with the paddles
  2. Restrict the paddles and the ball to move on Pong pixels (four times the size of Pandora pixels)
On another note; how much garbage collection is handled automagically by Penjin and how much do we have to handle ourselves? This game won't be very popular if it breaks everybodies Pandas. :)
 
MarkoeZ said:
The zero issue is fixed, and there is a background tune. It still error's on exit sometimes though, even though i added the stopmusic code :S. could you take a look at that perhaps?
I'll have a glance over it, see if anything jumps out.

Miggles said:
On another note; how much garbage collection is handled automagically by Penjin and how much do we have to handle ourselves? This game won't be very popular if it breaks everybodies Pandas. :)
Eep... well I've run the framework through valgrind many times to get rid of any leaks, but you should definitely keep track of your own pointers you use!
States and Penjin classes tidy themselves up.
There is no garbage collection like in Java, because that's just C/C++ for you. You can get packages that add garbage collection/auto-pointer deleting etc, but I think it's better to get into the habbit to tidy up any dynamic memory you allocate!
 
Last edited by a moderator:
PokeParadox said:
Eep... well I've run the framework through valgrind many times to get rid of any leaks, but you should definitely keep track of your own pointers you use!
States and Penjin classes tidy themselves up.
There is no garbage collection like in Java, because that's just C/C++ for you. You can get packages that add garbage collection/auto-pointer deleting etc, but I think it's better to get into the habbit to tidy up any dynamic memory you allocate!
It's a good sentiment but I'm a long way away from figuring out what I'm actually doing. Pong isn't a problem because I'm only using basic floats and ints on the State object and no pointers. My current one is giving me real headaches trying to pass around an array so I'm currently investigating using lists or vectors instead (any one of which is going to need cleaning up).
 
Last edited by a moderator:
Miggles said:
PokeParadox said:
Eep... well I've run the framework through valgrind many times to get rid of any leaks, but you should definitely keep track of your own pointers you use!
States and Penjin classes tidy themselves up.
There is no garbage collection like in Java, because that's just C/C++ for you. You can get packages that add garbage collection/auto-pointer deleting etc, but I think it's better to get into the habbit to tidy up any dynamic memory you allocate!
It's a good sentiment but I'm a long way away from figuring out what I'm actually doing. Pong isn't a problem because I'm only using basic floats and ints on the State object and no pointers. My current one is giving me real headaches trying to pass around an array so I'm currently investigating using lists or vectors instead (any one of which is going to need cleaning up).

You don't have to use pointers to use vectors.
If you have msn or similar, pm your username, I'll try and help you out... or if you can post a snippit of code or something. You should have many problems unless you are trying to do something complex...
 
Last edited by a moderator:
MarkoeZ said:
The zero issue is fixed, and there is a background tune. It still error's on exit sometimes though, even though i added the stopmusic code :S. could you take a look at that perhaps?
I think I managed to find your bug... it wasn't directly with the music...
It's due to order the engine's functions are called Input, update ,render.
It was trying to play the music after it had already been freed... somehow...
I'm not 100% sure but I added in a bool and a check and it seems to be fixed now...

Additionally I added checks in the main engine to hopefully prevent lockups...
Release hopefully before I need to sleep :p

EDIT updates uploaded!

I need help with the Wiki! I had "bad shit" happen and long story short is my site died and the wiki disappeared. :/
I can't find my backups either... sigh
EDIT2: I found a backup of the Wiki!!
EDIT3: Wiki is safe, I updated it a little.

The downloads for PandoraPanic are safe on a different part of the server, but I have no clue what happened... ick
 
Last edited by a moderator:
PokeParadox said:
I think I managed to find your bug... it wasn't directly with the music...
It's due to order the engine's functions are called Input, update ,render.
It was trying to play the music after it had already been freed... somehow...
I'm not 100% sure but I added in a bool and a check and it seems to be fixed now...
oh ok, that's way out of my league, for now at least ;)

And good to see that my backgrounds are the way they are supposed to be with the transparency fixed.
Starting to look smooth(er ; )

Cheers!
 
Last edited by a moderator:
Miggles said:
If anyone can spare a moment, I'd like a little pointer on pointers. :)

I need shapes to be an array of pointers to OBBShape objects (so I only need to load each sprite once and can reference each one as many times as needed without consuming vast amounts of memory or doing lots of in-memory copies) but I'm having a problem with the name = n line.
Miggles,
If you just want to use copies of a SDL surface, use a straight pointer copy and increment the surface refcount value. That way the original image is always used and any SDL_FreeSurface() call just decrements the refcount until the last one (original image) which is then deallocated fully.

CODE

class Surface
{
...
Surface & operator=(const Surface &rhs)
{
if (this != &rhs)
{
this->cleanUp(); //delete any prev _surface
this->_surface = rhs.surface();
rhs.surface()->refcount++;
}
return *this;
}

void cleanUp()
{
if (_surface) SDL_FreeSurface(_surface);
_surface = 0;
}
//Surface class has a member of:
SDL_Surface *_surface
}



P.S pass your strings (objects) by ref or pointer rather than value (faster).
CODE

void OBBShape::initShape(const string &n) {
name = n;
}
//or
void OBBShape::initShape(const char *n) {
name = n;
}
//or both (overloaded)
 
Last edited by a moderator:
PurplePup said:
If you just want to use copies of a SDL surface, use a straight pointer copy and increment the surface refcount value. That way the original image is always used and any SDL_FreeSurface() call just decrements the refcount until the last one (original image) which is then deallocated fully.
P.S pass your strings (objects) by ref or pointer rather than value (faster).
CODE

void OBBShape::initShape(const string &n) {
name = n;
}
//or
void OBBShape::initShape(const char *n) {
name = n;
}
//or both (overloaded)




I'll freely admit I don't understand quite what's going on with the first one. I'm thinking this means that sprites are surfaces in SDL (which I guess makes sense as you do all the same blitting) and the neat bit is that you can have multiple references to the same sprite but using different positions and the like? Is this possible in Penjin, PokeParadox?

If it is, that's cool but it's not quite what I'm after.

On the other hand, pointers and references are and I think I'm getting there.

I have been having a serious problem trying to construct an array of shapes (each with a pointer to a sprite) and what seemed to be happening was that any subsquent sprite added to the array would overwrite the image data of the first sprite in the array. I suspect I was doing something very silly when creating these sprite objects but I haven't gone back to look because I've been busy implementing a linked list and using that for my collection of images. Which is actually a lot more relevant than an array and (as an extra special added bonus) is actually working now. :)

So thanks for the help.
 
Last edited by a moderator:
If anyone needs some art done I'll do it..
I can't code anything but I'd like to help out somehow.
This goes for any other game being developed too. I can do 2d graphics in any flavor and some basic 3d in maya, which is pretty useless :D

er sorry if im making a fool of myself
 
Miggles said:
I'll freely admit I don't understand quite what's going on with the first one. I'm thinking this means that sprites are surfaces in SDL (which I guess makes sense as you do all the same blitting) and the neat bit is that you can have multiple references to the same sprite but using different positions and the like? Is this possible in Penjin, PokeParadox?
It is possible, but would require some thought about how to implement it with the classes.
 
Last edited by a moderator:
PokeParadox,
In the updated framework, how do we assign which colour is the transparency colour for sprites? I can find setAlpha but that sets global transparency rather than individual transparency.

Also, what is the difference between update() and unlimitedUpdate()?
 
CODE
//or
void OBBShape::initShape(const char *n) {
name = n;
}

Bad idea! Because you are copying the value of the pointer and not the data that the pointer is pointing to, this can easily lead to a crash. e.g.

CODE

int * pInt = NULL;
void PointCopy( int * pAInt )
{
pInt = pAInt;
}

int main()
{
{
int blah = 10;
PointCopy( &blah );
} // variable blah is now popped off the stack

// Crash. pInt is left dangling as the data it was pointing to is freed/no longer there
std::cout << *pInt << std::endl;
}

If you are dealing with strings, always prefer std::string over char *.
 
Miggles said:
PokeParadox,
In the updated framework, how do we assign which colour is the transparency colour for sprites? I can find setAlpha but that sets global transparency rather than individual transparency.

Also, what is the difference between update() and unlimitedUpdate()?
It's still currently auto from the top-left pixel. I'm adding in function that will let you over-ride it.

update() updates at the same rate as the rate you set for screen updates.
unlimitedUpdate() updates as many times as it possibly can.

Basically anything that uses it's own timer may be better placed in unlimitedUpdate, if not you can use the screen update timer.
 
Last edited by a moderator:
PokeParadox said:
It's still currently auto from the top-left pixel. I'm adding in function that will let you over-ride it.
That's kind of trippy. At the moment all of my sprites are showing the magenta all around and one of them has a transparency in the middle where the orange square was. :)
 
Last edited by a moderator:
Back
Top