I like Newgrounds stuufff
Unemployed and poor
Middle School Dropout
100 Mile House BC Canada
Joined on 10/2/15
Posted by ninjamuffin99 - 1 month ago
What up Newgrounds. Today I went though some dumbass bullshit with coding, and I figured I'd share the behind the scenes process of some dumbshit that can happen when you program. Maybe you'll learn a thing or two. Or maybe I'll be a terrible explainer. Who knows. Maybe I wrote this to process and vent and get it all out of my system. Hopefully I explain it all nice and it's an interesting read. Tell me if you find any typos.
A bit of context, I'm using HaxeFlixel, which is based upon OpenFL, which is based upon how flash does things. So maybe if you're familiar with any of these you can understand a bit better, or learn something about these.
The problem was that when posting the game as HTML5, the game does NOT scale to the viewport/stage/whatever.
Let's say your game was 300x250 in size. That's about the size of an average retro pixel art game I think. If you were to upload it to Newgrounds as a HTML5 file, you would have to set the viewport to 300x250 exactly, and it would be a tiny window on screen. Even if you tried to set it to a higher res, it would just be a tiny window within a window. It goes the other way too. Let's say you had a 1920x1080 res game, and you wanted to upload it to NG. Well, if you don't have proper scaling setup, the viewport only shows a small portion of the full image.
(Let's say the browser window is the Newgrounds viewport. Works basically the same way anyways. The browser window in this case is about 680x460. The game here is about 200px. As you can see it doesn't fit the full window nicely)
(And in this instance, the game is like 1000px, way too big!)
There are likely a few solutions to this. Luckily, OpenFL has a super simple one. It's essentially a switch you can flip. OpenFL has a little file you can edit, called Project.xml. It has all sorts of parameters, and modifacations you can make to make the program work differently. XML is similar to HTML in style, so I'll just post a code snippet and explain.
<window if="html5" resizable="false" />
the "window" part says that it wants to modify the window attributes. The "if" says this line will only work if the html5 code define is set (it gets set automatically depending on which target you are building for). Now you'll see what we're after. The "resizeable". This sets it so the program display scales nicely to whatever window size we want. All we have to do is change "false" to "true". And voila!
(How it SHOULD have worked)
Seems like a simple fix right? It usually is. That's how I got my other projects like Monster Mashing, or the Christmas ADVENTure collab to work on mobile. On Newgrounds, when you're playing a mobile game, the viewport size is automatically set to your phone's browser window. So whether you have a 192x108 phone size, or a 1920x1080 phone size, the games WILL be somewhat of a consistent size. The aspect ratio fixing is a bit of a different post itself, so I won't get into that. But what I'm saying is I HAVE done this before, and it worked just fine. But for some reason...it just didn't this time?
(How it actually worked the first time I tried it)
I pretty much triple checked that 'resizable' was true. I made sure that the Project.xml file was nearly the exact same as the other projects that I KNEW worked. So what's the issue? I'm using an additional framework called DjFlixel. It's like a bunch of helper classes and whatnot for HaxeFlixel. It does a bunch of neat things, like cool UI shit, better control handling, and making it so that you can hot-reload assets during runtime, so that you don't have to recompile after every little change. I recommend checking it out. I wondered if that was the issue? I did a bunch of shit to it. Nothing seemed to be working though. I even started a fresh project, to see if the default setup somehow broke for me. But the fresh one worked just fine. I added all my code to it to see if it worked. Nope. I straight up refactored a bunch of code to not use ANY parts of DJFlixel. Stuff was still broke.
Haxe has a little package manager style system, similar to npm, which is the package manager for Node.js (npm is short for node package manager duh). Say I wanted to make a game with HaxeFlixel. Instead of putting a HaxeFlixel folder within my actual source code (I believe you had to do something similar for oldschool AS3 flixel games), I can install HaxeFlixel to the 'haxelib' which is short for haxe library I guess lol. So it's like a code library in a way. Like an extension of your source code. You can use those pieces of code in your own source code, without having to directly include it, if that all makes sense. I'm preeeetty sure it's just for organizational purposes. BUT BASICALLY it's as if all that code was in your source code folder and you can use it like normal.
I need to explain that because there's another difference between this project, and Monster Mashing, an example where it could resize properly. Monster Mashing uses DjFlixel too. Although, sliiightly differently. Monster Mashing uses DJFlixel by actually including the code within it's own code, rather than through haxelib. So if you were to look at the Monster Mashing source code, you'll notice that djflixel is a folder within source/ . I did that just so that I didn't have to deal with installing it on haxelib on the different PCs I work on lol. I was also fine with that because I only used it for ONE feature that DJFlixel has, which is a fader that fades the screen in steps, rather than smoothly.
(Credits scene for Monster Mashing. The fade effect is similar to retro games, so that's why I used it rather than the smooth default that HaxeFlixel uses.)
So I went about and added DJFlixel through the regular old adding it to my folder shit, and this time.... it was still broken. Except it was actually a black screen rather than the game just not properly resizing. The game gave me no helpful error logs. I decided to explicitly compare the Monster Mashing files, and these current files. First was the Project.xml. That was pretty much identical. Next was Main.hx, which is as expected, the main file. The files were also pretty much identical. Except I was missing a single line. I didn't call the function that actually sets up the game. How did I slip up here you may ask? Well, when I was refactoring a smidge of code, migrating between DJFlixel and 'vanilla' lets say, DJFlixel automatically called the game setup function. So I deleted the line that explicitly called it. This shit got me face palming hard. Think of it like you're trying to start animating. You turn on your PC, you get your tablet plugged in. And you're wondering why Flash isn't opening. Why is that? Well, it's because you didn't even click Flash to open it yet you dumbass. Imagine constantly rebooting your PC, unplugging and replugging in your tablet. But Flash "just won't open". But for the past 30 minutes you straight up just haven't even clicked on Flash to open in the first place. That's pretty much how dumb I felt.
So I called the setup game function all properly, and then the screen was no longer black! AND the screen resizing worked! I even re-enabled my old code that used DJFlixel stuff, and that worked too! So everything was somewhat back to normal. I figured it was some dumb combination of things, that I somehow fixed along the way, since I was essentially back to where I started, as if "resizable" was set to true all along. So I deleted the DJFlixel folder, and went back to using it from haxelib. And what happened next? The screen scaling stopped working. I was basically at square one at this point. As if the past hour or two was meaningless. What's the solution? I could just leave the shit in the folder, but all this told me was there was something in the DJFlixel haxelib folder that isn't in my folder. And I was right.
In haxelib, or really any sort of library of code you have in haxe, you can use an 'include.xml' file. These work pretty much exactly the same as Project.xml files. You can set different variables, like window res, which libraries you need for your own library, shit like that. If you install DJFlixel, that NEEDS HaxeFlixel to work, so maybe in there you'd see
<haxelib name="flixel" />
Note, flixel in this case refers to haxeflixel.
And then you'd need haxeflixel in your haxelib. I'd never messed around with include.xml files, mostly because I never needed to. I haven't written my own library yet, and everything has always just worked more or less fine enough for me when using stuff from Haxelib. However, in the DJFlixel include.xml file, there was a certain line that I saw immediately that sorta shocked me..
<window if="html5" resizable="false" />
DJFlixel was overriding the "resizable" variable and setting it to false no matter what. I turned that to true. And everything worked now. Scaling worked perfectly as well. It also had a few other defines set, that overrode a few things I needed to set. So I was able to get mobile controls working as well, just like Monster Mashing.
So that's basically mission success. What I assumed would be a literal 2 second solution, where I change "false" to "true" in that Project.xml, well it turned out to take me about 1-2 hours. What's the moral of the story? I'd say make sure you know what you'er using when you use all these fancy libraries that you didn't write yourself. And also if you're the one writing these libraries, make sure you got good documentation to tell the people what exactly you're doing, changing, and overriding. And uhh also coding is like 95% bullshit, and sometimes you get to actually write code if you're lucky. Also 4th moral of the story is that if you give up you'll never achieve your dreams. 5th moral is that magic is real and anything is possible, especially when it comes to programming.
If I feel like it I'll probably write some more little posts like these as I stumble my way through programming.
If you made it through this post uhh tell me if it all makes sense. I try to write it so it doesn't just make sense to other programmers, but the average person as well. And while you're listening and obeying all my orders, follow me on Twitter, and check out my Github if you wanna actually see how truly bad I am at programming. Everything I make is open source.
Posted by ninjamuffin99 - 1 month ago
That's right. No clickbait. No exaggeration. Monster Mashing has been banned. From Steam, that is.
Alright I'll admit that was a little clickbait. I assume you thought MM was banned from Newgrounds, but the game is still available here: https://www.newgrounds.com/portal/view/707498
The first little thing that was suspicious was that it took AGES for Valve to approve/review the game. They claim it's because NSFW games require more in-depth reviewing, because some territories ban certain types of games or something like that. HOWEVER, what was much more surprising was when the Monster Mashing steam page suddenly disappeared a few days ago. When you tried going to the link, it just brought you to the Steam store homepage. Personally I was notified by this when someone on Twitter DM'd me telling me the MM storepage wasn't there anymore. Maybe Valve was just being stricter with the NSFW filtering tools? Like if you aren't signed into Steam and saying that you want to see 18+ content, the page didn't show whatsoever. It wasn't until we checked the Valve partner backend when we saw that big red "APP HAS BEEN BANNED" message when we knew the situation. But even then, we didn't. We still didn't know exactly why we were banned. From my knowledge, Monster Mashing was a softcore-ish adult game. It didn't have sex scenes, it didn't even show nips in the Steam version. It had moaning? And shit some very revealing rips and tears in the clothing. On the Steam version that is. The thing that got us? The Vine girl
(Art by @cymbourine , this is NOT the in-game art, but I'm too lazy to actually find it lmao. You get the gist though. Also go follow Cym lmao. The actual art looks a tad more childish but maybe its just different art styles or something.)
They said it was because she was underage lookin. And they straight up won't allow that. Well that's it I suppose. Maybe we can appeal, and we'll either have to fully redo Vine girl, or axe her from Steam version. We'll have to see.
To end on a somewhat nicer note, this makes me very much appreciate the places that allow us to upload the game as-is. No changes, no weird policies. These places more or less allowed the game with little to no changes, so these places are very good and I VERY much love and appreciate them for not banishing us.
If you wanna see the slight differences between versions, read this newspost: https://ninjamuffin99.newgrounds.com/news/post/1045960
GO BUY OR PLAY IT LMAOOO PRAY FOR US
Posted by ninjamuffin99 - March 19th, 2019
Pretty much every single game I've ever programmed is open source. Every single released game, and almost every prototype. They are hosted online on Github.com, a website where you can check out the full code, as well as the full development history. Everything from the first line of code ever written, to the final touches I added right before I release (or abandon) a project. There are a bunch of reasons why I do this. And why I appreciate other open source projects.
When I really got started making games was when I learned about HaxeFlixel in mid-2016. It's a fully free and open source framework, which is based off of Adam Atomic's 'Flixel' framework, which was used for many popular and famous flash games (Canabalt, Dino Run, probably way more lol). My first game I posted to NG pretty much ripped code straight from one of the HaxeFlixel demos (the code was open source, I didn't have to reverse engineer or anything), which showcased tweens. I liked the movement of one of the tweens so I nabbed that shit and added some other animation code. So instead of starting completely from scratch, I was able to work off an already existing demo, which was made in a pre-existing framework, which was an extension of an ALREADY existing framework. It all nicely builds on top of each other to make game development more accessible. There's an argument to be had about whether or not I'm actually learning, but I believe this is a better first step for programmers than starting completely from scratch. Let's also use game modding as an example. There's a lot of people in the game's industry, as well as game dev hobbyests, who started out making mods for games. Maybe it was a Half-Life 2 mod, where you made your own fan interpretation of what HL3 could be. In that process you likely learned a lot about level design, scripting, and story telling that you wouldn't otherwise learn if you had to start completely from scratch. Everything relies on what's already established and known. I believe you can sorta work your way backwards in a sense. If you had to start from scratch, you'd have to maybe learn C++ to build your own game engine, then you'd have to figure out good engine design, and then likely your homemade engine is very barebones, and the game you create might not even be as fun or interesting as some shitty game mod you made. If you start out at the top level, learning about level design, scripting, etc., you can work your way backwards, or should I say, downwards, in the stack or whatever. Maybe after learning about level design, you can learn about how the level editor is made, and then you can learn some C++ to see how that works, and then you have some knowledge of C++ so you can then learn some stuff about the engine in general and programming patterns associated with it. That is, if the engine is open source. If you build that familiarity with the engine at a high level, you can work your way downwards and associate functions and whatnot with how you know it works in a real scenario. I feel like open source is empowering in that sense.
I sorta open source my stuff to pay back the universe or whatever. If these people kept their code secret, if Adam's Flixel wasn't open source, if HaxeFlixel wasn't open source, and if the HaxeFlixel demos weren't open source, then maybe I wouldn't even be making games. Or at least I'd be much more behind in terms of what I know. I was able to look right into the code and see exactly how shit works, what other programmers did, and learn from it all. Maybe I saw a demo that showed some cool visual effect. Even if the code went over my head, I could maybe get one little code trick from it. And then I could iterate and modify it myself and shit evolves. I never went to a university for programming, no one taught me really. I went through that 'flixel-tutorial' by Schulles on this site, and then looked at other peoples code from there. I get to see the inside look at shit. Before I officially know any programming patterns, I already have a slight understanding of a few of them, just through sorta absorption and seeing the diverse ways in which different people code different projects.
So to go off that last point, I also like to think that maybe one day my code can be of some sort of educational use. Now I don't mean that people will be studying it in school. More maybe some kid who wants to get into programming sees one of my games, then they could see exactly how I went about to do certain things. They don't need to go to some big university or school and pay some dumb amount just to learn. They just need to access the internet, and they could learn how games are made. If they say, want to make an infinite runner, maybe they can take a peak at how Monster Mashing does things. If they want to make a topdown shooter, they can see the wacky trigonometry stuff I did in Pico Rising. If they want to see how ANYTHING in my games is done code wise, they could. Everything from the full game, to some throwaway effect. One other thing is that there are far more games with closed source code, than open source code. Especially 'commercial' games. So most of the open source stuff is highly polished, well commented code. I feel like this might give somewhat of an unrealistic expectation of programming, since often you don't find the most elegant solution to a problem. Often you have a mess of variables or some dumbass poorly written functions, but it all works. And that sort of code has a personality of sorts. It's rough around the edges, but it gets the job done. However most of the time, you just see this perfectly sterilized code. All commented, no workarounds, just straightforward. And that's helpful too, especially to beginners who may have never seen a line of code in their life. I just think there's value in seeing the process, and that pretty much everyone just bullshits their code. Everyone from some schmoe who's working on their first game ever, to some dev who's been coding for years and years. Noel Berry, 1/2 of the programmers who worked on Celeste, open sourced the player class of Celeste. It was filled with all these little quirks and odditys, but it all worked. You could see the exact values of how gravity affects Celeste, how it affects her jump, or double jump. You could see the workarounds, the shortcuts, and know that all of that, it went into one of the most successful indie games of 2018. I think stuff like this wakes people up in a sense.
I also like to feel like I'm contributing to the normalization of releasing source code. The open source 'movement' or whatever is huge, but in terms of game source code, it's not to normal. There are 2 examples that come to mind, and have inspired me to consistently share my source code, even when I do a 'commercial game'. The first is Quadrilateral Cowboy, by Blendo Games. QC released on Steam in 2016, for like 20$ or something like that. However the full game's source code is still available online for free under the GPL license. The other example is more close to the Newgrounds community, because it's NG's own Nicky Case (@nutcasenightmare). EVERY recent project by Nicky has their source code released under the CC0 (zero rights reserved aka public domain) license. You don't need to attribute, you don't need permission, you can use it for ANYTHING with no restrictions. These project's have gone on to get IGF Award nominations (Coming Out Sim by Nicky got a Narrative nomination in 2014, Quadrilateral Cowboy won the Seamus McNally GRAND PRIZE in 2017). One of Nicky's games is one of the highest rated submissions on the site, and their projects also got Nicky into Forbes' famed "30 Under 30" list. So shoutout to Nicky, and shoutout to Brendon Chung of Blendo Games. Technically if you release your source code, you're basically giving your game out for free. Some people who open source their game feel safe in doing so because they made an online game, where you can't connect to the servers if you build your own version. However I look at it similarly the way I look at piracy. If people play your game for free, and you made a good ass game, it's likely they want to support you and give you money. The people who won't give you money are either people who didn't like your game and wouldn't have given you money anyways, OR they just couldn't. Maybe it's some poor kid who runs your game at 18FPS on his shitty laptop, or maybe it's someone who has Steam blocked in their country or someshit. IDK all the wild and wacky scenarios in which people pirate, but people will pirate your game whether or not you have DRM, if it's open source, or if it's online only. It's not people who would've bought your game but people who can't or won't buy it. Buy maybe I'm just a dumbass and a bad business person.
On the grander scale, I appreciate large open source projects because they're majorly collaborative. Site's like Wikipedia are FULLY powered by the community. They don't have advertisers nor investors to pay bills. They have a huge community of people chipping in very small amounts to contribute and donate. ALL of the content on Wikipedia is curated and written by THE PEOPLE. Anyone from some homeless man who's visiting the local library, to a big famous celebrity could edit a page. Wikipedia has a few hundred employee's I believe and I think it's pretty impressive that they're essentially a crowd funded site. I find it very inspiring to see such a large community of people work towards something like that on a large scale. Companies like Amazon, Google, or Intel, sure they can all make ridiculous donations to Wikipedia, but they get absolutely nothing in return that you already don't get. They don't get exclusive edit access, they don't get ad space (asides from a placement on their wall of rich people lol), and they don't get secret wiki's or anything. They get the same thing that the person donating 5$ gets, or the person donating 500$ gets, or the person donating absolutely nothing ever gets. They get what is essentially the sum of all human knowledge, for free.
You can check out Wikimedia's Github page here: https://github.com/wikimedia
Aside from Wikipedia, there are cool examples of people working together on open source projects for pretty much nothing in return.
A cool case I like to think back on is OpenToonz. Back when it was released, I feel like no one knew how to even use it. It wasn't intuitive whatsoever. You had to change all these settings, and there was all this dumbshit you had to do just to get a simple test animation going. And also maybe it wasn't that stable. However over the few years since it's initial release as open source software, it has improved at a great pace. And a good chunk of that is because of the community around it. I saw this first hand back when I kept a closer eye on the project back in 2016. If someone had a bug report, they could post it to the Github issue tracker, and if someone felt up to it, ANY random developer could fix it. Meanwhile, there are Flash/Animate bugs that have probably persisted for years before they get addressed and fixed (if they get fixed at all!). On OpenToonz, people talk about what's being fixed, why something can't get fixed, and how something could potentially be fixed. Any schmoe could ask a question directly to developers. Other than tweeting at Adobe or directly contacting support, you don't get any communication with them. On OpenToonz, maybe you have a cool idea for a feature. You could post it to the issue tracker, and again, a random developer could implment that feature during a lunch break if they wanted. Or they could tell you exactly why that wouldn't work, and you could learn something.
You can peep OpenToonz Github here: https://github.com/opentoonz/opentoonz
I feel like people don't give enough credit to open source shit. Maybe they think it's inferior to proprietary software. Like free shit =/= quality shit. However open source software is used everywhere, but you almost don't even know it. That's because it's the bigger companies like Twitter, Google, Facebook, all use open source software themselves in their products. While their main sites aren't open source or anything, it's not like they're completely ignoring the value of open sourcing certain aspects of their code. Many big companies have somewhat of an open source presence. One that comes to mind immediately is Microsoft. First of all, in 2018 they bought Github for 7.5 BILLION dollars, the biggest website for hosting and exploring software source code. MS also have a very popular code editor, Visual Studio Code, which is free and open source. And VS Code isn't just some random code editor, this is an editor that a large majority of programmers use on a daily basis. I believe they also open sourced MS-DOS sometime recently. I do believe Microsoft is working towards being a company that's cool and hip, but in an actual cool and hip way. A lot of the gripes people have had with Microsoft was when their old CEO was in. I think in 2014 or something they got a new guy, and that felt like a sorta turning point. I mean one of the first big acquisitions after the new CEO rolled in was when they bought Minecraft/Mojang for 2.5$ billion. And you can say what you want about what they've done with MC, but I feel like they're trying to move in the right direction for stuff like the Minecraft education editions, where they know the unique engagement that players have with Minecraft, and utilizing it in a way that benefits their knowledge and education outside of the game. In a similar sense, I feel like they understand the power that open source has as well. In 2016 they became a Linux Foundation Platinum Member, while one of their old CEO straight up said, "Linux is a cancer". I look forward to the future of Microsoft's (and other giant tech companies') open source endeavors.
In some cases, open source and free version of a software is somewhat of the standard, and I feel like it couldn't have gotten in that position without being free and open source. Take OBS (Open Broadcasting Software) for example. OBS is basically used to record and/or livestream from your PC. You could record and stream in any quality, to any service, for as long as you want, without any watermarks. This sounds like simple shit, but that's because gone are the times of UNREGISTERED HYPERCAM, dealing with Bandicam, or paying for X-Split. Before OBS, there wasn't really a good free option. Part of it could also be attributed to the way technology just changes through the years, obviously in 2009 you couldn't be recording 1080p 60FPS footage off a Pentium 4 processor with integrated graphics, but like I said there were very little good free options then. It took the collaborative work from dozens and dozens of programmers and contributors to get OBS to where it's at today, which is the software that pretty much every single Twitch streamer uses on a daily basis.
Peep OBS source code here: https://github.com/obsproject/obs-studio
Technically, Newgrounds itself has an open source project, Swivel. @Mike open sourced it in late 2017 (maybe early 2018), but the software itself was available fully for free since 2013 or so. Although the development isn't very active (I'm pretty sure Mike works at The Behemoth full time) it's still nice to know that if you're a proficient enough developer, you can contribute to something that many animators use and rely on. It's written in Haxe, which is a nice language that I also use, so if you happen to know it you should dig around the Swivel source. That also sorta became a standard of sorts for SWF to MP4 conversion for Flash animators.
One other piece of open source software I really like is Blender. I haven't used any of the alternatives (Maya or 3DS Max or whatever), but I'm preeeetty sure it stands comfortably alongside them. And as far as I know, it's the only free software to do so. Blender is stupidly powerful with what it can do. In 2018, the Netflix Original movie "Next Gen" came out, and that movie was pretty much entirely made within Blender. I believe they used other software like Photoshop for texture painting, Houdini for particle effects, but all the modelling, rigging, animation, shaders, were done in Blender. I'm likely leaving out a bunch of details, so here's a link to a talk about how Blender was used for that movie. Also check out Next Gen, it's really good.
This post sorta devolved into me talking about different open source projects, and there are way more that I love and appreciate. Here's a quick list
Shit maybe this was a bad newspost but if you're reading this u cute
If I got stuff wrong or worded stuff badly please tell me so I can fix it and not look like a dumbass. There's a whole lot more I can talk about in terms of open source so drop a comment and I'll reply because I like the attention.
I LOVE OPEN SOURCE SHIT
PEEP MY GITHUB: https://github.com/ninjamuffin99
Posted by ninjamuffin99 - March 15th, 2019
Well, almost. The storepage is up and you can wishlist it pls pls
If you REALLY wanna buy it RIGHT NOW you can do so via Itch.io (comes with Steam key) or Nutaku (Fully uncensored). It's available for Windows and Mac, and if you buy these two versions, you also get an Android build FREE OF CHARGE.
If you buy it on Itch.io or Steam, those versions are integrated with the fancy ass newgrounds.io API, which basically means you can log into your Newgrounds account through the desktop versions, and be able to post to the Newgrounds leaderboard and get medals. Sadly Nutaku doesn't allow games to open links so we can't open the newgrounds sign in page to load the API stuff properly.
If you feelin real crazy and baller, you can buy it on every site, for a total of 9$. That's like 3x the money i think
THAT IS ALL BUY THIS GAME LOLOL