The 2D game lib is a basic framework for creating 2D platformer type games in StarCraft 2 which makes gratuitous use translate kinetics (a new data type added in 3.0). With some modifications, the game lib could be used to for any games with a WASD / 8 directional movement controls or even just games with basic 2D physics (tetris, angry birds, flappy bird, canabalt, etc).
How?
The X and Y velocity of each unit is stored as a custom value. Every game tick, the velocity for each unit is applied via a combination of translate kinetics. Since a maximum of 4100 kinetics can be applied at once, kinetic data is broken into digits (X 1.0, 2.0, 3.0, etc / 0.1, 0.2, 0.3, etc / 0.01 , 0.02, 0.03) and direction (+X for right, -X for left, +Y for up, -Y for down). Because these kinetics have a duration of 0.0625, there is no stacking of applied kinetics across game ticks, allowing units to be moved accurately. Kinetic application occurs in the "Translate Unit Horizontally" and "Translate Unit Vertically" function (inside the Translate Unit function that's run for each active unit in the "Each Game Tick" trigger).
The attached library's "Each Game Tick trigger" runs a host other functions to simulate 2D platformer physics, such as applying friction or air resistance based on unit state, basic collision, speculative contact, and applying gravity.
You can modify game data such as hero move speed, jump height, restitution (bounciness) or game data data such as gravity strength, friction, and air resistance in the Global Record Variables.
Known Issues / Caveats
Maximum horizontal and vertical unit velocity is 9.99 map units per game tick (0.0625 seconds). This could be increased by adding more kinetic data, but does anything really need to move that fast?
Top right / left corners of units may unrealistically clip through bottom corners of static collision units due to the position of the top side collision test. This will be fixed in the next version by using multiple top side collision tests.
Storing unit data (move speed, jump height, etc) in records is less than ideal. A better solution will be implemented.
Fast moving units may clip through 0.5 x 0.5 sized static collision units. I generally advise against using them (but had to create the pipe in Super Sonya Bros 1-1)
Next Up
Support for slopes! This will allow for Sonic-like levels
Further Optimization. Please let me know if any code screams "optimize me". Current candidate areas include kinetic application and speculative contact functions (speculative contact is the most resource intensive operation by far).
Requested Features. Leave a request in this thread and I'll give it a shot.
Special Thanks
To ArcaneDurandel/ArcanePariah for an introductory exploration of kinetic data, and for designing a kinetic wizard so I didn't have to write all 108 kinetic / apply / remove / remove all effects by hand.
Various 2D platformer game dev tutorials and stack exchange threads. Particularly this one.
The demo level doesn't have any instances of a ton of fast units moving... ah I shouldve added a debug command to spawn bouncy coins so you can try to crash the game =D
2D Game Lib v0.8
What?
The 2D game lib is a basic framework for creating 2D platformer type games in StarCraft 2 which makes gratuitous use translate kinetics (a new data type added in 3.0). With some modifications, the game lib could be used to for any games with a WASD / 8 directional movement controls or even just games with basic 2D physics (tetris, angry birds, flappy bird, canabalt, etc).
How?
The X and Y velocity of each unit is stored as a custom value. Every game tick, the velocity for each unit is applied via a combination of translate kinetics. Since a maximum of 4100 kinetics can be applied at once, kinetic data is broken into digits (X 1.0, 2.0, 3.0, etc / 0.1, 0.2, 0.3, etc / 0.01 , 0.02, 0.03) and direction (+X for right, -X for left, +Y for up, -Y for down). Because these kinetics have a duration of 0.0625, there is no stacking of applied kinetics across game ticks, allowing units to be moved accurately. Kinetic application occurs in the "Translate Unit Horizontally" and "Translate Unit Vertically" function (inside the Translate Unit function that's run for each active unit in the "Each Game Tick" trigger).
The attached library's "Each Game Tick trigger" runs a host other functions to simulate 2D platformer physics, such as applying friction or air resistance based on unit state, basic collision, speculative contact, and applying gravity.
You can modify game data such as hero move speed, jump height, restitution (bounciness) or game data data such as gravity strength, friction, and air resistance in the Global Record Variables.
Known Issues / Caveats
Next Up
Special Thanks
https://mega.nz/#!KBxwTITB!aBqWPFFLpHhgcI4uScKMyLeQgGbIup_PWXBt88dlvy4
@PirateArcade | I make games | Ask me things on Discord
This is crazy! AMAZING!
Marie T. Freeman If you're too busy to give your neighbor a helping hand, then you're just too darned busy. https://www.facebook.com/wargirlmaps.maps
Spread the love join DISCORD
https://discord.gg/Jtzt8Su
Madness.
"What do i look like? An orc?" - Artanis after being poked.
Join our mapmaking Discord server and let's reach the 100th member mark! https://discord.gg/EGa6EPE
Vote in my poll: What do you do best!? http://www.strawpoll.me/12207821/r
I'm going to test this on my laptop (which meets almost perfectly the minimum requirements of SC2) and see how it goes.
Edit: 75 FPS constantly.
"What do i look like? An orc?" - Artanis after being poked.
Join our mapmaking Discord server and let's reach the 100th member mark! https://discord.gg/EGa6EPE
Vote in my poll: What do you do best!? http://www.strawpoll.me/12207821/r
Unreal!
@Caevrane: Go
Good to know!
The demo level doesn't have any instances of a ton of fast units moving... ah I shouldve added a debug command to spawn bouncy coins so you can try to crash the game =D
@PirateArcade | I make games | Ask me things on Discord
Someone make a Super Smash Brothers-based game plz O.O
"What do i look like? An orc?" - Artanis after being poked.
Join our mapmaking Discord server and let's reach the 100th member mark! https://discord.gg/EGa6EPE
Vote in my poll: What do you do best!? http://www.strawpoll.me/12207821/r
@Caevrane: Go
agreed please make one
Marie T. Freeman If you're too busy to give your neighbor a helping hand, then you're just too darned busy. https://www.facebook.com/wargirlmaps.maps
Spread the love join DISCORD
https://discord.gg/Jtzt8Su
@wargirlwargirl: Go
Would need a pro animator... would love to do but only like 3 heroes from storm have jump animations
@PirateArcade | I make games | Ask me things on Discord
Super Mario Maker in starcraft O.o
@greythepirate: Go
ME ME ME ME
I just so happen to be a pretty good animator, my main modeling field, actually!
"What do i look like? An orc?" - Artanis after being poked.
Join our mapmaking Discord server and let's reach the 100th member mark! https://discord.gg/EGa6EPE
Vote in my poll: What do you do best!? http://www.strawpoll.me/12207821/r
@Caevrane: Go
Wait really?
@PirateArcade | I make games | Ask me things on Discord
Yup.
The "Custom Footman" model actually has animations made completely from scratch.
In the signature below. v v v v v
"What do i look like? An orc?" - Artanis after being poked.
Join our mapmaking Discord server and let's reach the 100th member mark! https://discord.gg/EGa6EPE
Vote in my poll: What do you do best!? http://www.strawpoll.me/12207821/r
@Caevrane: Go
Awesome! PM'd
@PirateArcade | I make games | Ask me things on Discord
Wow, this looks pretty neat.
Is the demo published on bnet by any chance? I would like to see how responsive controlling is, in an online game.
@greythepirate: Go
Is this really happening?
Marie T. Freeman If you're too busy to give your neighbor a helping hand, then you're just too darned busy. https://www.facebook.com/wargirlmaps.maps
Spread the love join DISCORD
https://discord.gg/Jtzt8Su
:O :O :O
How about Blackthorne 2? :D :D
Who is in for making Super Smash SC for real?
@SyCoAttack: Go
I'm willing to do some work on it here and there, could be fun