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 / Same code runs differently on windows/android/html5

Author
Message
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 8th Mar 2017 18:08
Hi there,

I've been writing a game using AppGameKit for a while and feel I have a fair understanding of it, but when I compile my program on anything but windows, my variables all go wonky.
I have attached my code and media so it can be investigated.

the gameplay is simple enough, but to test the bug, run the code and select 1 player game, then click on the portrait of player 2 (Angela Merkel) or player 3 (Steven Harper) choose to use mass media and select one of their cities, sure enough when it plays out the turns that is what you will be told. If you then load the code onto your device (android anyway ) and do the same test, when it comes to perform your action, it will be against a different player.

Any ideas as to what I can do to stop that happening?

Attachments

Login to view attachments
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Mar 2017 22:50
i did not see something attached.
AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 9th Mar 2017 10:15
sorry, when I tried to upload it before it clearly didn't work. Have taken the sounds out from the media folder and made it slightly smaller and it has worked now.
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Mar 2017 10:54
don't know how to test.
Quote: "and select one of their cities"


select 1 player game, ok
then click on the portrait of player 2 (Angela Merkel) ok
choose to use mass media ok
and select one of their cities??? i can only click at the avatar icons, then the map scroll, and then ?

AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 9th Mar 2017 11:10
the "cities" are those little houses on the island. When you click on player 2, the screen scrolls to her island. once you have clicked mass media and it says "select a target" just click on one of the houses.

Attachments

Login to view attachments
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 11th Mar 2017 09:45
Is there somewhere I can forward this to as a proper bug report? its not much use if the code you write deploys differently on different platforms.
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Mar 2017 11:30
i can not see houses
AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 15th Mar 2017 23:47
I also do not see any houses, screenshot attached.

Attachments

Login to view attachments
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 16th Mar 2017 12:10
yep sorry, this is my fault i think, the program looks for citytest.txt in the media folder, but for some reason, when i looked there is a "citytest - Copy.txt" change the name of the file or the code (line 2360) and then it should work. It must have been loading the correct file from the temp directory or something for me, hence it was working. You should be able to test it now.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 16th Mar 2017 15:17
if you want the same random then use SetRandomSeed(#) with a known value that gives the desired result
it gives the same results from Random() number calls (as long as the code is exactly the same on all devices of course, for instance when running multiplayer you might call an extra random on only 1 by by mistake which messes up the sequence)
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 19th Mar 2017 10:05 Edited at: 19th Mar 2017 10:09
Holy crap on a corncob - thousands of lines of code and just one single function and zero types to organize it all properly. How do you keep sane trying to debug the thing? Or trying to introduce new functionality?

I get the reference though - Nuclear War on the Amiga back in the days. Was a great little game if combined with a couple of friends and a few beers.
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 21st Mar 2017 10:44
heh, not sure i do keep sane debugging it all. I just print loads of my variables to screen and then try to follow my logic to deduce what's going wrong, Not got any sort of formal programming training. yeah Nuclear war is the influence here, just thought it would be a good template for a local "pass the tablet" sort of experience.
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 22nd Mar 2017 15:31
Formal training or not - there are a few simple guidelines to making good code. Good in this context meaning easy to read, follow and debug.

- Don't repeat yourself. Got something you do again and again with only minor deviations? Pack it up in a function!
- Avoid multilayered nesting. Got If statements packed inside a select-case statement in a for loop triggered by yet another if statement? If you got three or more layers of nesting, abstract away into functions.
- Avoid globals. In AppGameKit some things do well to have access to all over, like image IDs, sprite IDs and such. But control-variables should be restricted and local - and if need be, passed by reference.
- Avoid discrete variables, pack them up into datatypes instead. Only temporary throwaway variables should be discrete. This makes it easy to pass data around, and add new fields and functionality into existing structures and code without doing a lot of editing of old code.
- Group functions by, well, function in separate files. If a function do input like say reading a key, have it in a file called 'input.agc' and import into main using #include "input.agc". Same with output, views, fileIO, httpIO etc. Makes it easy to find what you are looking for in a big project.
- Functions should do as little as possible to get *one* job done, but no less! So shorter functions is better than longer functions. Though, that said, don't be afraid of long functions. As long as it is focused on doing one job, all is well.
- Plan ahead. Not in any detail, but by main functionality. This helps with setting up initial structure and datatypes, which saves you a ton of work later on.

...and finally and most important:

- Make sure you're fully stocked up with coffee and caffeinated soft-drinks.
AlexD66
Silver Codemaster
12
Years of Service
User Offline
Joined: 8th Jul 2011
Location: stuck in the middle with you..
Posted: 24th Mar 2017 13:49
will try and keep some of these in mind as I'm coding thx

Login to post a reply

Server time is: 2024-03-29 11:32:08
Your offset time is: 2024-03-29 11:32:08