• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 22:02
CEST 04:02
KST 11:02
  • 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
Serral wins EWC 202535Tournament Spotlight: FEL Cracow 202510Power Rank - Esports World Cup 202580RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15
Community News
[BSL 2025] H2 - Team Wars, Weeklies & SB Ladder9EWC 2025 - Replay Pack4Google Play ASL (Season 20) Announced50BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams10Weekly Cups (July 14-20): Final Check-up0
StarCraft 2
General
Serral wins EWC 2025 The GOAT ranking of GOAT rankings Tournament Spotlight: FEL Cracow 2025 Classic: "It's a thick wall to break through to become world champ" Firefly given lifetime ban by ESIC following match-fixing investigation
Tourneys
LiuLi Cup Weeklies and Monthlies Info Sea Duckling Open (Global, Bronze-Diamond) TaeJa vs Creator Bo7 SC Evo Showmatch Sparkling Tuna Cup - Weekly Open Tournament FEL Cracov 2025 (July 27) - $10,000 live event
Strategy
How did i lose this ZvP, whats the proper response
Custom Maps
External Content
Mutation # 484 Magnetic Pull Mutation #239 Bad Weather Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune
Brood War
General
BW General Discussion Scmdraft 2 - 0.9.0 Preview [BSL 2025] H2 - Team Wars, Weeklies & SB Ladder Google Play ASL (Season 20) Announced Which top zerg/toss will fail in qualifiers?
Tourneys
[ASL20] Online Qualifiers Day 2 [ASL20] Online Qualifiers Day 1 [Megathread] Daily Proleagues Small VOD Thread 2.0
Strategy
[G] Mineral Boosting Muta micro map competition Does 1 second matter in StarCraft? Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Beyond All Reason Total Annihilation Server - TAForever [MMORPG] Tree of Savior (Successor of Ragnarok)
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
Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread Canadian Politics Mega-thread Stop Killing Games - European Citizens Initiative
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread [\m/] Heavy Metal Thread Movie Discussion! [Manga] One Piece Korean Music Discussion
Sports
Formula 1 Discussion 2024 - 2025 Football Thread TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment" Computer Build, Upgrade & Buying Resource Thread
TL Community
TeamLiquid Team Shirt On Sale The Automated Ban List
Blogs
ASL S20 English Commentary…
namkraft
The Link Between Fitness and…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Socialism Anyone?
GreenHorizons
Customize Sidebar...

Website Feedback

Closed Threads



Active: 592 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 7h 58m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
NeuroSwarm 223
Nina 184
StarCraft: Brood War
Calm 10583
Barracks 2170
ggaemo 144
Sexy 81
NaDa 56
firebathero 43
Aegong 33
Icarus 4
Dota 2
monkeys_forever856
League of Legends
febbydoto14
Counter-Strike
Stewie2K599
Heroes of the Storm
Khaldor168
Other Games
summit1g14027
JimRising 462
C9.Mang0380
ViBE229
ROOTCatZ25
Organizations
Other Games
gamesdonequick912
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• Berry_CruncH186
• davetesta46
• Hupsaiya 43
• gosughost_ 26
• practicex 20
• Kozan
• AfreecaTV YouTube
• intothetv
• sooper7s
• IndyKCrew
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• Azhi_Dahaki65
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22459
Other Games
• Shiphtur135
Upcoming Events
Sparkling Tuna Cup
7h 58m
BSL20 Non-Korean Champi…
11h 58m
Bonyth vs TBD
WardiTV European League
13h 58m
ByuN vs ShoWTimE
HeRoMaRinE vs MaxPax
Wardi Open
1d 8h
OSC
1d 21h
uThermal 2v2 Circuit
3 days
The PondCast
4 days
Replay Cast
4 days
uThermal 2v2 Circuit
5 days
RSL Revival
5 days
[ Show More ]
RSL Revival
6 days
uThermal 2v2 Circuit
6 days
Liquipedia Results

Completed

ASL Season 20: Qualifier #1
FEL Cracow 2025
CC Div. A S7

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20: Qualifier #2
HCC Europe
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025

Upcoming

ASL Season 20
CSLPRO Chat StarLAN 3
BSL Season 21
RSL Revival: Season 2
Maestros of the Game
SEL Season 2 Championship
WardiTV Summer 2025
uThermal 2v2 Main Event
Thunderpick World Champ.
MESA Nomadic Masters Fall
CAC 2025
Roobet Cup 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
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.