• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:59
CET 14:59
KST 22:59
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
ComeBackTV's documentary on Byun's Career !8Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15
StarCraft 2
General
When will we find out if there are more tournament ComeBackTV's documentary on Byun's Career ! Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win RSL Revival - 2025 Season Finals Preview Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump
Tourneys
Winter Warp Gate Amateur Showdown #1 Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship RSL Offline Finals Info - Dec 13 and 14! Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress
Brood War
General
Klaucher discontinued / in-game color settings Anyone remember me from 2000s Bnet EAST server? BGH Auto Balance -> http://bghmmr.eu/ How Rain Became ProGamer in Just 3 Months FlaSh on: Biggest Problem With SnOw's Playstyle
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] WB SEMIFINALS - Saturday 21:00 CET [BSL21] RO8 - Day 2 - Sunday 21:00 CET
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta Fighting Spirit mining rates
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Mechabellum PC Games Sales Thread Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
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
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread The Games Industry And ATVI YouTube Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1128 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
SC Evo League
12:30
#18
LiquipediaDiscussion
WardiTV 2025
11:00
Playoffs
Reynor vs MaxPaxLIVE!
SHIN vs TBD
TBD vs Cure
Solar vs herO
Classic vs TBD
TBD vs Clem
WardiTV1701
ComeBackTV 1263
TaKeTV 510
IndyStarCraft 267
Rex161
CosmosSc2 119
LiquipediaDiscussion
CranKy Ducklings
10:00
Master Swan Open #99
CranKy Ducklings49
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko325
IndyStarCraft 267
Rex 161
CosmosSc2 119
MindelVK 46
trigger 21
StarCraft: Brood War
Horang2 1887
EffOrt 702
Stork 582
firebathero 322
Leta 279
Last 199
ggaemo 144
Zeus 123
Larva 123
ajuk12(nOOB) 42
[ Show more ]
Mong 41
Bonyth 41
ToSsGirL 36
zelot 30
Shinee 26
yabsab 22
ivOry 11
SilentControl 10
Dota 2
Gorgc5417
singsing3807
qojqva1215
XcaliburYe243
League of Legends
rGuardiaN88
Heroes of the Storm
Khaldor259
Other Games
B2W.Neo1879
Pyrionflax365
crisheroes325
DeMusliM282
XaKoH 138
Hui .108
KnowMe59
Trikslyr26
QueenE25
Organizations
StarCraft: Brood War
lovetv 9
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• C_a_k_e 2404
• Gemini_19 27
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1978
• Nemesis1183
Upcoming Events
Ladder Legends
5h 2m
BSL 21
6h 2m
Sziky vs Dewalt
eOnzErG vs Cross
Sparkling Tuna Cup
20h 2m
Ladder Legends
1d 3h
BSL 21
1d 6h
StRyKeR vs TBD
Bonyth vs TBD
Replay Cast
1d 19h
Wardi Open
1d 22h
Monday Night Weeklies
2 days
WardiTV Invitational
3 days
Replay Cast
4 days
[ Show More ]
WardiTV Invitational
4 days
ByuN vs Solar
Clem vs Classic
Cure vs herO
Reynor vs MaxPax
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Offline Finals
Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 1
WardiTV 2025
META Madness #9
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL Season 19: Qualifier 2
CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.