• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:24
CEST 21:24
KST 04:24
  • 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
BGE 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[ASL19] Finals Preview: Daunting Task30
Community News
Weekly 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-back0EWC 2025 Regional Qualifier Results26
StarCraft 2
General
CN community: Firefly accused of suspicious activities Firefly do had match fixing The SCII GOAT: A statistical Evaluation How does the number of casters affect your enjoyment of esports? Serious Question: Mech
Tourneys
$3,500 WardiTV European League 2025 Bellum Gens Elite: Stara Zagora 2025 Sparkling Tuna Cup - Weekly Open Tournament SOOPer7s Showmatches 2025 Master Swan Open (Global Bronze-Master 2)
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
Will foreigners ever be able to challenge Koreans? BGH auto balance -> http://bghmmr.eu/ Mihu vs Korea Players Statistics BW General Discussion [BSL20] ProLeague: Bracket Stage & Dates
Tourneys
[ASL19] Grand Finals NA Team League 6/8/2025 [Megathread] Daily Proleagues [BSL20] ProLeague Bracket Stage - Day 2
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
Cognitive styles x game perf…
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
Poker
Nebuchad
Customize Sidebar...

Website Feedback

Closed Threads



Active: 22165 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 36m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
EnDerr 59
UpATreeSC 47
MindelVK 47
StarCraft: Brood War
Horang2 625
firebathero 152
Dewaltoss 92
Sacsri 26
yabsab 17
Movie 12
Counter-Strike
fl0m6358
olofmeister2293
rGuardiaN111
FunKaTv 44
Super Smash Bros
Mew2King65
Heroes of the Storm
Liquid`Hasu624
Other Games
tarik_tv45736
gofns16612
summit1g8549
B2W.Neo960
Beastyqt674
ceh9477
mouzStarbuck358
ArmadaUGS149
Pyrionflax104
ZombieGrub84
Trikslyr55
QueenE54
BRAT_OK 30
Organizations
Dota 2
PGL Dota 2 - Main Stream3090
Other Games
BasetradeTV94
StarCraft 2
angryscii 56
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• kabyraGe 270
• Adnapsc2 47
• Dystopia_ 3
• IndyKCrew
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
• Kozan
StarCraft: Brood War
• Azhi_Dahaki13
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21288
• Ler154
League of Legends
• TFBlade1084
Other Games
• imaqtpie1190
• Scarra534
• Shiphtur346
Upcoming Events
Replay Cast
4h 36m
Replay Cast
14h 36m
WardiTV Invitational
15h 36m
WardiTV Invitational
15h 36m
PiGosaur Monday
1d 4h
GSL Code S
1d 14h
Rogue vs GuMiho
Maru vs Solar
Online Event
2 days
Replay Cast
2 days
GSL Code S
2 days
herO vs Zoun
Classic vs Bunny
The PondCast
2 days
[ Show More ]
Replay Cast
3 days
WardiTV Invitational
3 days
OSC
3 days
Korean StarCraft League
4 days
CranKy Ducklings
4 days
WardiTV Invitational
4 days
Cheesadelphia
4 days
GSL Code S
5 days
Sparkling Tuna Cup
5 days
Replay Cast
6 days
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
ECL Season 49: Europe
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.