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 / Want support but not wanting to post code

Author
Message
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 1st Jul 2012 14:35
I want to get some support on an issue with my game but I don't want to post the code publicly. I know I could always make some derivative code to get a solution, but it could be an issue related to the way my project is set out.

Is there a bug submission process where I can send the code to internal staff only for bug fixing?
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Jul 2012 15:47
Quote: "Is there a bug submission process where I can send the code to internal staff only for bug fixing?"

There is a bug board (linked in one of the stickies) however, it's for bugs that lie within the AppGameKit language and not necessarily your programs. However, I'm happy to take a look at your code, just send me an email if you like.

Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 1st Jul 2012 16:10
Yeah, I don't know. Really I don't want anyone to see the game for now. Anyway I'm having problems with getSpriteHit(screenToWorldX(getPointerX()),screenToWorldY(getPointerY()))

It crashes if I click at a specific point on the screen on a sprite behind another sprite. Total annoying. Guess I'll just delete the function and start again.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Jul 2012 18:49
It's highly unlikely that function is causing the problem. I use it an awful lot with no problems just as you show it. If you aren't willing to share then you'll have to find the bug yourself, I don't recommend ignoring it as it may just crop up again later.


this.mess = abs(sin(times#))
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Jul 2012 20:43 Edited at: 2nd Jul 2012 00:24
Psycho - as baxslash rightly suggests, the spirit of the forum is to share help, and that means sharing a few crucial bits of code. Nobody wants to see or steal your game.

Please try to make a small demo of the problem, and also say which platform, whether it's Basic or C++ or Pascal, and how it can be reproduced. There's a huge repository of expertise here, with immediate feedback to TGC. Sometimes it'a a bug in the engine that's causing a problem, but probably 90% or more of the time it's because none of use are perfect.

-- Jim
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Jul 2012 21:20
Isolating the problem as a code snippet to post for help, quite often gets you the answer. If you can't recreate it in isolation, your implementation is most likely flawed.

If you can recreate it in isolation...then you can post it without revealing your game.

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 2nd Jul 2012 01:59
Quote: "Yeah, I don't know. Really I don't want anyone to see the game for now. Anyway I'm having problems with getSpriteHit(screenToWorldX(getPointerX()),screenToWorldY(getPointerY()))

It crashes if I click at a specific point on the screen on a sprite behind another sprite. Total annoying. Guess I'll just delete the function and start again. "


Is the error sprite 0 dont exist?

Because then you nead get sprite hit test to ignore if its overlapping or not.

Check the documentation so will you see wath i mean.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 2nd Jul 2012 03:15
Okay thanks guys for the support. I'll see if I can extract the code to show the problem.

Yes I would say it's a sprite does not exist error even though all I'm clicking on is sprites.

It's just one weird spot either side of the screen that crashes it.

I'll look into the overlapping issue in the docs too.
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 2nd Jul 2012 13:26 Edited at: 2nd Jul 2012 13:29
Psycho Psam, if your device somehow scales the picture, then you get borders at both sides of the game screen on the device. If you click on these borders, the getpointerx() and y, still report coordinates outside the screen, and that can be a problem.

I fix this by using modified versions of those commands like:



This assume virtual resolution of 1280*800 (Galaxy tab 10.1)

The galaxy tab forces in a menu line at the bottom of your screen, and thereby slightly compressing the picture of your app, so small borders will appear at both sides, even if you have the resolution to the native one of the device, in other words, GT10.1 SUCKS!

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 2nd Jul 2012 14:49
Well I used that function but when I reduced the code down this seems to be the offending code. Once I click in the region I want I call this code to determine where the mouse is in screen coords before calling the GetSpriteHit - which I've commented out right now to determine why it crashes.



was from this code

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Jul 2012 15:49
What do you do with the variable "sprite"?

Do you check that it has a value, then do something if it has one? If so it could be what you do next that actually causes the crash. I hope that makes sense!


this.mess = abs(sin(times#))
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 2nd Jul 2012 17:17
Well sprite was going to be part of a test to see which "button" you clicked on. But it crashes without even getting that far. I wish AppGameKit had debugging.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 2nd Jul 2012 18:05 Edited at: 2nd Jul 2012 18:25
Okay this worked - no idea what the difference is - but ... I used GetSpriteHitTest instead and checked for each individual sprite before proceeding. I would rather using GetSpriteHit to find out which one - but what's weird is I never used GetSpriteHit because I commented it out before...


Also this doesn't compile - I guess it likes a space after "if"
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 2nd Jul 2012 18:21 Edited at: 2nd Jul 2012 18:32
Found another place where it crashes


All icons work except icon2[1]. If I click on the icons in the menus using the code in my previous post, it crashes. But if I do the change below it works... a memory leak? What's weirder still is if I roll the code back to when it crashed before but leave this change in - it doesn't crash - perhaps this simple leak is causing the problem.
3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Jul 2012 18:50 Edited at: 2nd Jul 2012 19:03
as I have found AppGameKit is not a good language to make gui's with. Dark gdk, and dark basic are much better to make gui's with unless this is a game. AppGameKit I think is only a game application and nothing more really. Plenty of people on these forums have attempted to make a windows based application with AppGameKit and it has not ended well. I also tried to make a GUI with AppGameKit, and found that it lacked the necessary things that dark gdk and dark basic already had.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 3rd Jul 2012 03:27
Well I need some sort of button press action to enable things in the game - so how are other people doing? It's all sprites right?

(not sure why that code about causes a leak)
XanthorXIII
AGK Gold Backer
13
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 3rd Jul 2012 04:45 Edited at: 3rd Jul 2012 04:48
Are you in T1 or T2?
Did you first DIM the array to give it a specific size or are you just trying to assign memory locations before you first do that.
I know silly question but we have to start somewhere.
And to be honest, do you really need an array to do that through?
Why not use Constants and use a Select/Case Switch.
Would allow you to do many things with that.
You create your sprites using the constant value to assign the sprite id and then do a test for Sprite Hit getting back the id of the sprite touched and then use a the Select/Case switch to handle each of the Outcomes.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 3rd Jul 2012 04:54
Quote: "Well I need some sort of button press action to enable things in the game - so how are other people doing? It's all sprites right? "

I use sprites for menus but I don't use GetSpriteHit(), instead I just do a box check which is practically this:

The downside to this is that you need to run it for each menu sprite.

Quote: "Are you in T1 or T2?"

Judging by his code snippets, I'd assume he's using T1.

Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 4th Jul 2012 13:57
Yep I assume I'm T1 too. I think. How can I tell?

The reason I used an array is because as the player upgrades the number of options in the menus will grow.

@Hodgey - that was my first thought - but then I found this wonderous GetSpriteHit function and thus my troubles began.

Oh yeah and I think string literals crash the code too. I was having a problem with this. See where I use print("in here") - caused the program to crash without even entering that part of the code. If I removed the print function call it didn't crash. So I think the interpreter might be getting stuck on actual strings, and really just wants variables.

Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 4th Jul 2012 13:59
Yep just confirmed it - if I changed it to print(gGroundTarget) it worked fine - but print("in here") crashes it
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Jul 2012 18:07
You are using Tier 1. Tier 1 is the Basic language and usually done with the AppGameKit IDE.

Also, it would help to know what version of AppGameKit you are using. You can tell, probably, what version you have by opening the AGK.txt file in your AppGameKit directory. About the third line down it should say what build it is. The most current is 1076.

The print statement with literals does not cause crashes by itself. I've used it many times.

I'll have to assume that gGroundTarget is a string, otherwise your print statement with that should not work.

From the code segment you posted, you don't appear to set gCurrentSprite to zero after you delete it. When the if statement gets executed a second time, it will definitely fail. It is probably actually failing on the "SetSpritePosition( gCurrentSprite, gPX, gPY )" call.

Cheers,
Ancient Lady
AGK Community Tester
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 5th Jul 2012 01:45 Edited at: 5th Jul 2012 02:03
I have 1076.

gGroundTarget is a sprite.

The point is the moment I put print ("in here") in the code which shouldn't affect anything, the moment I activate that code it crashes the game.

I just tested it again. I put in the following lines and it works fine.


Then when I add the next line - it crashes when the code is activated - ie the menu opens.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 5th Jul 2012 01:58 Edited at: 5th Jul 2012 02:04
Regarding DIM'ing the variables first, yes I did, but then I just did another test. I moved this code back to the main.agc instead of being called in a function it item.agc and it works fine.


But the moment this code is put back into item.agc and called there is the DIM icon2[4] in main.agc it crashes unless I use the fix. It crashes when I click on icon in-game to utilise it.
1) So in main.agc is the statement DIM icon2[4]
2) Then it calls a function in item.agc with gosub loadItemsIntoMenu
3) In loadItemsIntoMenu the code above is called (minus the DIM icon2[4] of course because it's in the main.agc).

Unless I do this fix to it sitting in items.agc it crashes when I click on the sprite.


It must have something to do with including scripts yes?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Jul 2012 04:52 Edited at: 5th Jul 2012 04:53
While, in theory, any dim'ed object is made global, that doesn't really work. It is also a good idea to explicitly type all variables. Replace 'DIM icon2[4]' with 'global DIM icon2[4] AS integer'.

I have been having a big problem with some recent code added to my WIP game. When the app is run on an iOS/Android device, it crashes sort of randomly in one routine. I've been through the routine and all the functions it calls extensively (I have 30+ years programming experience) and there should not be a problem.

The Xcode diagnostics started giving me clues. It kept insisting that I was trying to deallocate a value that hadn't been allocated. Sometimes it indicates that it is a string (based on the line of code in interpreter.cpp that it fails on) and others it is a sprite (my interpretation of the assembly language line from the library from some file named cSprite.c(pp)).

I know I am handling the sprites correctly (unless function call variables are being scrambled, and they are constant integers being passed).

I tried moving all my static strings to global variables and using the globals. That worked for a bit and then the crashes came back.

I have a strong suspicion that the garbage collection is not working properly.

I'm converting my app to Tier 2.

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Jul 2012 06:15 Edited at: 5th Jul 2012 06:29
First, print statements with variables are okay. You can't use them concatenated with strings, but they work fine by themselves.

This works...





but this does not work...



Second, you gotta keep in mind that variables declared in functions are local to that function. So...



will always have the nImage referred to in the print statement as a value of zero. If you use the same method to create a sprite in a function then you'll get a crash because there's no sprite zero allowed.

But...



will work fine, because the nImage variable used in the function is global, and thus is the same variable called in the print statement.

So the variable iconImage declared in a function, unless declared global outside the function, will return zero when referenced outside of the function. And a sprite created with a local variable in a function will not be the same sprite referenced in a local variable with the same name outside that function.

Try this...


and you'll see what I mean.


In AppGameKit, arrays are always global, so you don't have to bother declaring them global.

Third, when AppGameKit crashes, it can be problematic to find the cause if you are adding several lines of code.

It might be that the error is in the line that attempts to delete gCurrentSprite, which might be zero because of #2 above.

I have had no problems with printing string literals. If you truly are having problems with printing string literals, then maybe a reinstall of AppGameKit would fix it.

EDIT: I got no clue why my code and /code tags aren't working.

I used to hate the thought of governments having orbital mind control satellites,
but now I can't really seem to care.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Jul 2012 06:18 Edited at: 5th Jul 2012 06:19


I used to hate the thought of governments having orbital mind control satellites,
but now I can't really seem to care.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 5th Jul 2012 17:14 Edited at: 5th Jul 2012 17:18
Setting the DIM to global DIM icon2[4] as integer certainly did fix this memory leak - hurrah! 1 success I've commented it out now that it works. Still adding the print statement in my code above didn't resolve that aforementioned issue - oh well. Perhaps I should upgrade to Tier2 to see what's going on under the hood.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Jul 2012 17:35
Rich, about 10 minutes after my post I realised that I was wrong. As long as you don't mix a number and a string, it works, as you said.

Psycho, I could have sworn I posted this, but I think part of your problem may be not setting gCurrentSprite to zero after you delete it. Unless you set it to another sprite before the "if gCurrentSprite <> 0 and gEditMode = 1" gets called. If you try to set the position of a sprite that doesn't exist (because you deleted it), the app will crash.

It might appear that it is happening when you click on a sprite, but sometimes it takes a bit for the crash to manifest.

Try putting this before 'SetSpritePosition( gCurrentSprite, gPX, gPY )' to see if what I describe is the problem:


Cheers,
Ancient Lady
AGK Community Tester
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 31st Jul 2012 12:26
This is resolved as mentioned in this thread. I was trying to mix gosubs and function calls. You can't.

http://forum.thegamecreators.com/?m=forum_view&t=199054&b=41

Thanks for everyone's help

Login to post a reply

Server time is: 2024-11-23 19:37:11
Your offset time is: 2024-11-23 19:37:11