Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier 1 to Tier 2 conversion help please

Author
Message
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 10th Nov 2017 12:42 Edited at: 10th Nov 2017 15:43
Hey,
I've let my C++ skills dwindle away and decided it's time to get them polished up again - I didn't realise just how rusty they had become!

To kick things off I decided to convert some Tier 1 code to Tier 2. Last week I banged together a quick and easy parallax scrolling demo so I thought that would be a good thing to convert.

Here is the Tier 1 code:


And my attmept at conversion:
.h

.cpp


The error I am getting is "Vector iterator not dereferencable"
and it highlights this: for (std::vector<int>::iterator itspr = itlay->spr.begin(); itspr != itlay->spr.end(); ++itspr)
(line 65 in the code snippet)

I'd really appreciate some guidance because I can't see what is wrong with it.

Thanks
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 10th Nov 2017 13:47
Hmm, I use in my code tons of these iterations. It almost looks like yours. The only difference is that I write 'itspr++' as '++itspr'.

You could also try the following. But should not really make a difference.

instead of

The last thing that should work. But it woud be more of a workaround.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 10th Nov 2017 15:43 Edited at: 10th Nov 2017 15:43
I found the error

It wasn't with the highlighted line although that line continues to be highlighted as though it is in error .... strange!

The error was a few lines further down. This:

Should be this:


Thanks for looking into though MadBit. Any help is always appreciated
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Nov 2017 02:08
I had once written a similar class. That was when I trying to write a DarkGDK replacement engine. Maybe you would like to get some inspiration. Or adjust the class for AGK.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Nov 2017 07:22
Thanks MadBit,

I got mine working, it was pretty much there once I fixed my bug.
I did make one other change - I had used a CreateLayer() function because I had one in the Tier 1 code but since I had a Layer constructor sitting idle I moved the code into that.

Always good to see someone else's code though and see how they tackled a similar problem.

Thanks

Login to post a reply

Server time is: 2024-11-24 06:13:05
Your offset time is: 2024-11-24 06:13:05