• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:53
CEST 20:53
KST 03:53
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Voting3[ASL20] Ro4 Preview: Descent6Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Weekly Cups (Oct 6-12): Four star herO65.0.15 Patch Balance Hotfix (2025-10-8)71Weekly Cups (Sept 29-Oct 5): MaxPax triples up3PartinG joins SteamerZone, returns to SC2 competition325.0.15 Balance Patch Notes (Live version)119
StarCraft 2
General
Ladder Impersonation (only maybe) 5.0.15 Patch Balance Hotfix (2025-10-8) The New Patch Killed Mech! TL.net Map Contest #21: Voting Weekly Cups (Oct 6-12): Four star herO
Tourneys
Master Swan Open (Global Bronze-Master 2) Tenacious Turtle Tussle WardiTV Mondays SC2's Safe House 2 - October 18 & 19 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
External Content
Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers Mutation # 492 Get Out More
Brood War
General
BSL Season 21 BW caster Sayle BGH Auto Balance -> http://bghmmr.eu/ Brood War web app to calculate unit interactions Whose hotkey signature is this?
Tourneys
[ASL20] Semifinal B [ASL20] Semifinal A [Megathread] Daily Proleagues [ASL20] Ro8 Day 4
Strategy
Current Meta BW - ajfirecracker Strategy & Training Siegecraft - a new perspective TvZ Theorycraft - Improving on State of the Art
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread ZeroSpace Megathread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
SPIRED by.ASL Mafia {211640} TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Men's Fashion Thread Sex and weight loss
Fan Clubs
The herO Fan Club! The Happy Fan Club!
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Inbreeding: Why Do We Do It…
Peanutsc
From Tilt to Ragequit:The Ps…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1199 users

It begins - Part Two

Blogs > Soan
Post a Reply
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
November 15 2013 01:22 GMT
#1
Part One

This Week
Hello again TeamLiquid!

Welcome back to my blog about the development of The Adventures of Sam the Pirate, the 2D platformer I'm creating as the final game project for my Bachelor of Software Engineering degree. This week I'll be talking about some of the technical stuff behind Sam the Pirate, including what it is being written in, where I'm am at the moment, and where I'm headed over the next couple of weeks.

The Foundation
C++ and Simple DirectMedia Layer (SDL) are being used as the foundation to create The Adventures of Sam the Pirate. This does mean that there is a fair bit of initial work to be done at the start, versus using something like Unity, however I'm more comfortable doing this and using C++ than using an already existing engine. I do have previous experience with Unity, however I get more personal satisfaction and simply enjoy creating games in C++ more than using existing tools like unity. It's certainly a much bigger challenge, essentially writing it from scratch, but I'm quite excited about it.

I chose to use SDL as it works in C++, cross-platform, distributed under the zlib license so free to use for any project. The cross-platform support means that it could be released on Mac and Linux, but at the moment that's something I'll be looking at after the initial PC release. The lack of access to Mac/Linux machines, and my lack of experience with them, means I can't really do anything about it at the moment anyway, even though I'd like to at some point.

So far SDL has been very good, it's very easy to work with, and very quick to get something rendering on the screen. I followed these tutorials to get started, so if you're interested in looking at SDL they're a good place to start. As Sam the Pirate is a 2D project, I'm using SDLs built in 2D renderer, and not using OpenGL at all. As far as I can tell at the moment, it should be sufficient for what I want to do, so if I get performance issues with the rendering later down the line, I guess I'll either have to do some heavy optimization or crunch and convert the rendering to use OpenGL.

Probably the biggest challenge I'm going to face on the coding side of the project, is the physics. Originally, I had planned to use an existing 2D physics engine such as Box2D. After a comment from one of my classmates, thinking about it some more and doing a bit of research, I changed my mind and decided to write my own from scratch. There are a two reasons for this:
  • May have to fight the physics engine to get the desired platforming behaviours
  • Don't need everything that comes with a physics engine

See the situation in the image below, where the green box is a bounding box for the stick figure character(Forgive my awesome paint skills!):
[image loading]

Using a physics engine, it would be expected for the green box to fall off the platform. In a platforming game, I wouldn't necessarily expect that to happen until the character is completely off the platform. To get the expected platformer behaviour using Box2D, I'd have to hack away at the collision response and prevent the green box from tumbling down. There's a similar situation with moving platforms, as collision response would need to be hacked away at to make the character stick to the moving platform.

The second reason is probably the biggest reason for not using a physics engine, they'll simply come with way more functionality than I need. I don't plan on doing anything particularly complicated, so I don't need a full on physics engine. Combined with the previous reason, it's probably time efficient to write something relatively simple that does what I need, rather than implement a full on physics engine and fight with it to get what I want. If something doesn't work how it should, writing my own code will also be easier to debug than using a big complicated physics engine. I'll cover more about how I implement the physics in a future blog post.

Recent Progress
Over the last couple of weeks, I got rendering up and running and implemented logging to a file, to the screen, and implemented a console, similar to what you see in some games. As SDL does not have native support for rendering fonts to the screen, I'm using SDL_ttf, which seems fairly slow to render text. It does look like there is a more efficient way to do it using glyphs, rather than just rendering a line of text, but I'm not 100% sure how that would work and don't really have time to investigate it at the moment. It's not so slow that it's causing any problems, and given that all of this logging is just for debugging purposes, so will not be present in the release build it shouldn't be a concern.

One of my goals with creating a debug console, was to create it in such a way that I could add console commands without modifying the code behind the console. To accomplish this, I used Lua scripting. The exact method feels pretty roundabout to me, but it works, and that's the most important thing. The image below shows an example of a command that sets the sprite with unique ID 0, to the position (100,100):

[image loading]
  • The first section, sprite, is the name of the .lua file to open.
  • The second section, setposition, is the name of the function inside the .lua file to call.
  • The last three sections are the parameters to be passed to the setposition function.
  • The parameters are comma separated, and follow the format type-value. In this case three integers are being passed.

The console parses the command exactly like that. The lua function then calls a C++ function, in this case, in the sprite system, which then sets the position of the appropriate sprite. Adding new console commands is then just a matter of creating the lua file and function, creating the C++ function and telling Lua that it exists. A bit roundabout, as you can see, but it works and I'm pretty pleased with it.

What's next?
Over the next week I'll be getting animated sprites from spritesheets working, and starting work on the physics and controls. In next weeks blog I'll be covering a bit more about the game play, including mechanics, levels, enemies, and scoring.

Keep up to date!
Be sure to follow me on Twitter, and like the Facebook page to stay up to date on future content and blog posts when they happen. If you have any questions don't hesitate to ask, either through Twitter or Facebook!


*****
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 15 2013 04:20 GMT
#2
Thanks for posting this! As a 3rd year SE student it's pretty interesting.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
CoughingHydra
Profile Blog Joined May 2012
177 Posts
Last Edited: 2013-11-15 21:15:10
November 15 2013 21:10 GMT
#3
Hi! I've worked with SDL and I would definitely recommend these tutorials http://lazyfoo.net/SDL_tutorials/index.php. It even has a nice guide for setting it up in linux and mac http://lazyfoo.net/SDL_tutorials/lesson01/index.php.
I don't know what type of game your making but while I was programming a rts game I found the 2D rendering to be bit slow for it so you may consider using OpenGL (there's even a tutorial for using OpenGL with SDL in the previously linked website).

Good luck with the project!

EDIT:
Oh yeah, I used bitmap font insted of ttf, but it's a bit of a pain in the ass to draw your own font .
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
November 17 2013 19:41 GMT
#4
Thanks for the links, I'll definitely check them out at some point. I'm making a fairly basic platformer, so with any luck the 2D rendering should be sufficient. If not, well I guess I'll be crunching. :D
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2013-11-29 22:17:55
November 29 2013 22:11 GMT
#5
Don't know if it's too late, but physics programming is pretty much the hardest part of game programming (unless you do tile based). Use Box2D. Your classmate doesn't know what he's talking. Box2D will have any feature you would ever want. Use a kinematic body for your player controller.

In your contrived example all you'd need to do is set the inertia to zero, which means a body cannot rotate. You would not hack away at anything Just be careful of who you take advice from. Sure Box2D will have more features than you need, but it was made to be useful in any 2D game. There's a reason why it's so popular. I'm just pretty annoyed when I see poor advice given from ignorant (but good intentioned) programmers.

To put this into perspective, I know enough about physics engine programming to get a job working on game physics right now, and if I were making a 2D game engine like you, I myself would still use Box2D.
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
November 29 2013 22:42 GMT
#6
I'm just starting on the physics stuff now, and yeah my levels will all be tile based. This is the specific article that really leaned me away from using Box2D on my platformer, which to me, sounds like it had a lot of good points.

My plan at the moment is to just use AABBs for everything, with all my sprites being the same size/multiples of my tiles. Trying to keep things as simple as possible, and I believe I can write simpler code by not using Box2D. I have used it before, during our physics programming paper, (where we also used PhysX for a bit), and I had a major issue with Box2D seemingly stopping the simulation without crashing the program. All the objects would just pause, which was really annoying. I put breakpoints in, and everything seemed normal, so neither myself or my tutor could figure out what was wrong. So that's something I'd like to avoid running into again as well, especially given my time constraint.

Accurate collision detection is going to be the hardest part I think, but I'm sure I can find plenty of articles on accurate rectangle/rectangle collision detection on the internet, and I've done the simple stuff before. Either way I'm pretty confident I can get expected platformer behaviour from writing my own physics, and I enjoy a challenge anyway.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2013-11-30 01:07:56
November 30 2013 01:06 GMT
#7
Yeah everything that guy is describing would be remedied by using tile physics. Though you should know that tile physics does not primary use AABBs. Additionally, all the problems he described require custom code to provide the desired behavior. This code would have to be written whether or not you use Box2D.
Please log in or register to reply.
Live Events Refresh
OSC
18:30
Mid Season Playoffs
MaxPax vs GeraldLIVE!
Solar vs Krystianer
PAPI vs Lemon
Ryung vs Moja
Nice vs NightPhoenix
Cham vs TBD
MaNa vs TriGGeR
SteadfastSC87
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 656
SteadfastSC 87
IndyStarCraft 70
MindelVK 22
Railgan 1
StarCraft: Brood War
Calm 3861
Rain 1283
Bisu 981
Larva 483
firebathero 268
Mini 258
Dewaltoss 191
Hyun 124
Backho 91
Barracks 57
[ Show more ]
scan(afreeca) 26
NaDa 11
Dota 2
Gorgc8056
Fuzer 165
Counter-Strike
fl0m1373
pashabiceps799
FunKaTv 34
Heroes of the Storm
Liquid`Hasu255
Other Games
Grubby2581
FrodaN2067
Beastyqt677
ceh9596
B2W.Neo387
Skadoodle363
Mlord201
C9.Mang0139
Pyrionflax104
QueenE71
Trikslyr52
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• poizon28 218
• Adnapsc2 19
• davetesta18
• Reevou 4
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 3539
• WagamamaTV209
League of Legends
• TFBlade894
Other Games
• imaqtpie1236
• Shiphtur301
Upcoming Events
PiGosaur Monday
5h 7m
OSC
1d 4h
The PondCast
1d 15h
OSC
1d 17h
Wardi Open
2 days
CranKy Ducklings
3 days
Safe House 2
3 days
Sparkling Tuna Cup
4 days
Safe House 2
4 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.