• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:04
CEST 21:04
KST 04:04
  • 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
Code S RO8 Preview: Rogue, GuMiho, Solar, Maru0BGE Stara Zagora 2025: Info & Preview27Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL47Code S RO12 Preview: Cure, Zoun, Solar, Creator4
Community News
BGE Stara Zagora 2025 - Replay Pack0Weekly Cups (June 2-8): herO doubles down1[BSL20] ProLeague: Bracket Stage & Dates9GSL Ro4 and Finals moved to Sunday June 15th13Weekly Cups (May 27-June 1): ByuN goes back-to-back0
StarCraft 2
General
BGE Stara Zagora 2025 - Replay Pack Code S RO8 Preview: Rogue, GuMiho, Solar, Maru Jim claims he and Firefly were involved in match-fixing The SCII GOAT: A statistical Evaluation StarCraft 1 & 2 Added to Xbox Game Pass
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) Bellum Gens Elite: Stara Zagora 2025 $3,500 WardiTV European League 2025 Sparkling Tuna Cup - Weekly Open Tournament SOOPer7s Showmatches 2025
Strategy
[G] Darkgrid Layout Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 477 Slow and Steady Mutation # 476 Charnel House Mutation # 475 Hard Target Mutation # 474 Futile Resistance
Brood War
General
BGH auto balance -> http://bghmmr.eu/ FlaSh Witnesses SCV Pull Off the Impossible vs Shu BW General Discussion StarCraft & BroodWar Campaign Speedrun Quest Will foreigners ever be able to challenge Koreans?
Tourneys
[ASL19] Grand Finals [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET NA Team League 6/8/2025 [Megathread] Daily Proleagues
Strategy
I am doing this better than progamers do. [G] How to get started on ladder as a new Z player
Other Games
General Games
Stormgate/Frost Giant Megathread What do you want from future RTS games? Armies of Exigo - YesYes? Nintendo Switch Thread Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Vape Nation Thread European Politico-economics QA Mega-thread
Fan Clubs
Maru Fan Club Serral Fan Club
Media & Entertainment
Korean Music Discussion [Manga] One Piece
Sports
2024 - 2025 Football Thread Formula 1 Discussion NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
A Better Routine For Progame…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 41082 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
Next event in 4h 56m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 698
UpATreeSC 89
BRAT_OK 85
MindelVK 45
StarCraft: Brood War
Britney 5482
Sea 2347
Mini 602
Dewaltoss 187
Aegong 49
sSak 29
Sacsri 18
yabsab 18
Counter-Strike
fl0m6739
olofmeister3430
rGuardiaN90
Heroes of the Storm
Liquid`Hasu440
Khaldor182
Other Games
tarik_tv41497
gofns14072
Grubby1078
FrodaN848
Beastyqt600
ceh9449
shahzam282
Mew2King84
TKL 72
Trikslyr59
ZombieGrub54
QueenE48
Organizations
Dota 2
PGL Dota 2 - Main Stream1324
Other Games
BasetradeTV87
StarCraft 2
angryscii 48
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• davetesta29
• Reevou 6
• IndyKCrew
• sooper7s
• Migwel
• AfreecaTV YouTube
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• Michael_bg 6
• FirePhoenix3
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21280
League of Legends
• Jankos1602
• TFBlade1071
Other Games
• imaqtpie966
• Shiphtur364
• WagamamaTV165
Upcoming Events
PiGosaur Monday
4h 56m
GSL Code S
14h 26m
Rogue vs GuMiho
Maru vs Solar
Online Event
1d 4h
Replay Cast
1d 6h
GSL Code S
1d 14h
herO vs Zoun
Classic vs Bunny
The PondCast
1d 14h
Replay Cast
2 days
WardiTV Invitational
2 days
OSC
2 days
Korean StarCraft League
3 days
[ Show More ]
SOOP
3 days
CranKy Ducklings
3 days
WardiTV Invitational
3 days
Cheesadelphia
3 days
CSO Cup
3 days
GSL Code S
4 days
Sparkling Tuna Cup
4 days
Replay Cast
5 days
Wardi Open
5 days
Replay Cast
6 days
Replay Cast
6 days
RSL Revival
6 days
Cure vs Percival
ByuN vs Spirit
Liquipedia Results

Completed

CSL Season 17: Qualifier 2
BGE Stara Zagora 2025
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL 17: 2025 SUMMER
2025 GSL S2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Murky Cup #2
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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.