00:00
00:00
mr-johnson22
Newgrounds rox.

Age 31, Male

Software Engineer

Canada

Joined on 7/16/05

Level:
39
Exp Points:
16,486 / 16,890
Exp Rank:
1,360
Vote Power:
8.02 votes
Rank:
Police Sergeant
Global Rank:
6,301
Blams:
264
Saves:
1,174
B/P Bonus:
12%
Whistle:
Normal
Trophies:
2
Medals:
738
Supporter:
7y 24d

Polytris Bug Fixes & Newgrounds API

Posted by mr-johnson22 - January 20th, 2014


So it turns out there were a number of problems with Super Polytris (which you can play here: http://www.newgrounds.com/portal/view/631244), ranging from bugs to design oversights, and API features that just plain didn't work! So I've spent the time to fix them.

Below is a list of most of the big (ie noticable) changes I made. I'm documenting them for 1) anyone who cares to know what was changed, and 2) to share the lessons I learned about using the Newgrounds API. Considering there are a lot of gaping holes in the API's documentation, I figure it's a good idea for me to share what I now know so someone can hopefully learn from my mistakes.

-Dumb Bug #1: Local high scores are now always saved, not just when you submit them to a leaderboard. I didn't even know this was a problem until today (!) -- I had score saving working ages ago, but I recently made a "fix" somewhere that turned it off, and never tested saving again. In other words, I suck at debugging. SORRY :(

-Dumb Bugs #2&3: The game no longer crashes when you lose a life in a game of Fit Mode, or when you play a mode with a time limit of less than 10 seconds. I am very embarrased. :(((

-Tweak #1: Rotating pieces is now a bit closer to actual Tetris; S & Z pieces rotate in the same way they do in the original. Just line pieces rotate a bit differently but I bet (hope) you won't even notice.

-Tweak #2: Rotating pieces with "Centre Rotate" turned off now works a lot better, as pieces will rotate around a single tile rather than doing whatever they did before.

-API Fix #1: Clicking on a Shared Mode on the game's submission page actually does something now! The game will now launch in the Usermode Select screen with that mode selected. The reason this never worked in the first place is because I thought that a mode on the page that's clicked on (a SaveFile in the API) would be loaded when the game launches, but that's not the case. Instead, the webpage injects the .swf with special values, called "flashvars", named "NewgroundsAPI_SaveFileID" and "NewgroundsAPI_SaveGroupID" that contain the info needed.

Check out this article to learn more about flashvars: http://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html

-API Fix #2: All modes now have their own WORKING leaderboards. The reason leaderboards didn't work before was because I had scores as part of a mode's data, and made it so that submitting your score simply overwrote the data of the shared mode. As a result, I learned the hard way that users can't overwrite any SaveFiles that aren't their own.

I didn't use the API's native scoreboard because I thought using them would limit the game to having a set number of leaderboards, rather than being able to have one for each mode. Well, it just so happens that there's a nigh-hidden "tag" feature in API scoreboards--it's possible to post a score with a specific tag, and to read in scores that match that tag. This means I was able to use a single scoreboard to store each mode's high scores, each with their own tag!

Regarding the API bugs, I was hoping that they were kinks that would be magically sorted out after the game was submitted & fully integrated in the site. Turns out, previewing your game with Newgrounds' Project System gives you an *extremely* accurate view of what to expect when your game is ready.

So, enjoy the new & improved game! And hopefully you learned something useful about the NG API.

PS: HUGE shout-outs to PsychoGoldfish, who not only worked on the API in the first place but was was kind enough to give me a hand in solving my API issues. He's the one who provided me with the info to make both of the API fixes I mentioned.


Comments

Comments ain't a thing here.