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 / Need help building tier 2 android project

Author
Message
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 22nd Jun 2013 22:46 Edited at: 22nd Jun 2013 22:48
I've just done a quick test and it seems a small number of objects aren't being deleted.

No I'm not creating bullets every loop. Bullets are only created if isShooting == true, which is true when the left mouse button is held down. There's also a timer in place so 3 bullets are created every so often.

Here's the code...



The bullets are stored in a vector in the player class for tracking.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Jun 2013 23:01
At first glance it all looks fine. It might not be impossible that those small number of objects not being deleted is enough to cause issues during play. I don't know.

Does it behave well if you don't manually create bullets using the mouse? (Letting the automagic ones just happen.)

I am about to head out to watch a baseball game and need to prep properly (team t-shirt and hat to show support).

Just to make mischief, have you tried with the new v10814?

I was able to build the VS2010 template straight out of the box on that.

Since the Core.cpp file hasn't changed since v10813, the same VS2010 project will work with v10814 if you 'repoint' to where the libraries are (assuming you keep separate directories for each install, like I do).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 22nd Jun 2013 23:20
The same thing happens if I just have isShooting always true. The problem isn't with bullets not being created, they're just invisible and have no velocity so I don't think whether isShooting is always true or set buy mouse input would make a difference.

One thing I have just noticed, if I build in debug mode then run the exe manually everything seems fine. The bullet problems only appear when running the release version of the exe manually.

When you build and run in vs, doesn't that just build the project then "double click" the resulting exe for you? If so, I can't understand why its fine running in vs but not when loading the exe manually.

Enjoy your baseball game AL. I'm gonna finish work on the project for today and sit back with a beer or 10.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Jun 2013 23:37
The Debug vs Release mode is actually a clue of sorts.

I had a very similar issue and it came down to incorrect index usage in a dynamically created array.

It might sound odd, but try moving all the little variable declarations to the start of the associated method instead of inside loops.

That is one of the programming styles that actually does make me cringe.

When you put a variable declaration inside of a for or while loop, it creates a new instance of that variable every loop iteration. In theory, it is deleting that instance at the end of the loop. But it is a case of creating and recreating memory allocation (even if it is only 4 bytes for an integer) and having to manage that memory. (My programming background goes back to when we really did count every byte and every clock cycle.)

The declarations I am talking about are things like "float xx = GetX();" in the Player::Shoot method. The declarations for xx and yy are inside the loop. Now, in that instance, it is a clearly defined number of iterations. But in the bullet management loop, the "bool destroy = false;" gets executed some unknown number.

I would have other suggestions for basic organization, but that is the kind of thing best left up to the coder.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 23rd Jun 2013 03:37 Edited at: 23rd Jun 2013 03:39
I actually usually don't declare variables in the loop. I have been getting a bit sloppy lately. I've been in the frame of mind of just writing stuff that works for the now, then optimizing later.
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 30th Jun 2013 05:41
Ancient Lady, i have decided to go back and rewrite the engine from scratch, and my fist use of std::map seems to work. I'm only using it for storing objects atm in the form of map<int, Object*> and it seems to work.

I've uploaded the project and the the apk to try.

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Jun 2013 05:46
I was trying to use a bit more of a 'sophisticated' (?) std::map, where the index was two or three values.

It was in providing the hashing and comparison functions needed that it failed compiling in Android.

So, maybe with the more default bits it works better.

Good luck.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
wargasmic
18
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 30th Jun 2013 05:52
The only forms of map i used were <int, Object*> and <string, object/int>.

I'm gonna go out on a whim and say that using string in the map was the problem, but not sure why.

Will find out tomorrow.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Jun 2013 18:03
This is what I was doing, it worked just fine in Windows, but the android-ndk compiler couldn't handle it.

header file (TA_UCHAR is typedef'ed as 'unsigned char'):


code file:


It looked like a nice, elegant way to handle getting an index for a vector based on two values. It actually ended up being more space and effort than if I had just used a two dimensional array (and I went a different direction altogether in the end).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-11-24 15:23:37
Your offset time is: 2024-11-24 15:23:37