• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 03:46
CEST 09:46
KST 16:46
  • 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
Tournament Spotlight: FEL Cracow 20255Power Rank - Esports World Cup 202576RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15HomeStory Cup 27 - Info & Preview18
Community News
Google Play ASL (Season 20) Announced20BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams10Weekly Cups (July 14-20): Final Check-up0Esports World Cup 2025 - Brackets Revealed19Weekly Cups (July 7-13): Classic continues to roll8
StarCraft 2
General
Tournament Spotlight: FEL Cracow 2025 #1: Maru - Greatest Players of All Time I offer completely free coaching services Power Rank - Esports World Cup 2025 What tournaments are world championships?
Tourneys
Esports World Cup 2025 $25,000 Streamerzone StarCraft Pro Series announced $5,000 WardiTV Summer Championship 2025 WardiTV Mondays 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 #239 Bad Weather Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune Mutation # 481 Fear and Lava
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion Google Play ASL (Season 20) Announced Flash Announces (and Retracts) Hiatus From ASL Dewalt's Show Matches in China
Tourneys
[Megathread] Daily Proleagues [BSL20] Non-Korean Championship 4x BSL + 4x China CSL Xiamen International Invitational [CSLPRO] It's CSLAN Season! - Last Chance
Strategy
Simple Questions, Simple Answers [G] Mineral Boosting Does 1 second matter in StarCraft?
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Total Annihilation Server - TAForever [MMORPG] Tree of Savior (Successor of Ragnarok) 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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
UK Politics Mega-thread US Politics Mega-thread Stop Killing Games - European Citizens Initiative Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
[\m/] Heavy Metal Thread Anime Discussion Thread Movie Discussion! [Manga] One Piece Korean Music Discussion
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
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
Ping To Win? Pings And Their…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Socialism Anyone?
GreenHorizons
Eight Anniversary as a TL…
Mizenhauer
Customize Sidebar...

Website Feedback

Closed Threads



Active: 657 users

Student Game Dev Part Five - More Physics Things

Blogs > Soan
Post a Reply
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
December 13 2013 01:58 GMT
#1
Part One - It begins
Part Two - Technical Foundation
Part Three - Game Design
Part Four - Input and Physics

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. Apologies for the lack of a blog last week, I came down with the flu and didn't get much done, which has put me a bit behind! Last week I covered how I was handling input, and some of the work I started on doing the games physics. This week I'll be going over where I'm now at with the physics.

Movement
Since the last blog, basic left and right movement is in and working, complete with acceleration and deceleration. Jumping is in, as is some basic collision detection/response. You cannot control left/right directional movement while in the air, but that's next on the list. The intent is definitely that you'll be able to change direction at will while jumping. Jumping itself feels slow and wrong at the moment, but hopefully that just requires tweaking the numbers over the next couple of months until it feels better and looks more natural when compared to the rest of the movement.

At its simplest, the movement is calculated, using 2D vectors, like this:
velocity += acceleration * deltaTime;
position += velocity * deltaTime;


With deltaTime being the time taken to process a frame, and there are a bunch of other considerations like capping velocity to certain values to prevent craziness, and checking if the character has come to a halt or not. Acceleration is calculated whenever a force is applied to the physics actor, sort of using the trusty old f=ma equation that you may recognise if you ever studied physics at all.

acceleration += force / mass;


There are checks in here as well, to cap the acceleration to predefined values. Now this all looks really simple, and if you're better at physics than I am (the more advanced stuff especially has never been my strong point), you might be kind of horrified at how I'm doing things! In fact just now I realised I've got a plus equals in my acceleration, so I'm probably doing it all wrong, but it works, and that's the most important thing. It doesn't matter too much how it works, just that it does, and allows me to move on with production.

Collision Detection
Collision detection is also pretty simplistic. Everything in the game is represented in my physics code as a rectangle, or an Axis Aligned Bounding Box, AABB. Luckily for me SDL comes with a function for testing whether or not two rectangles are intersecting, so I don't even have to do any maths. The downside to this, is that it purely uses integers, rather than floats, which makes it kind of inaccurate. However I don't need accurate, so it's probably alright.

Using this method, there's some clear intersection going on when my player character falls onto the ground from a jump, rather than simply standing on top of it, but I was kind of expecting that. The SDL function does give me the position and dimensions of the intersecting rectangle, so I should be able to use that to detect what direction the collision is coming from, and adjust the moving character appropriately. Right now all I'm doing is halting the vertical velocity of the moving object, and ensuring that stays zero for as long as the player is on the ground.

If doing things so simply comes back to bite me in the ass in the future, well, I'll just have to deal with it.

What's next?
I have a milestone due next week, to meet it all I need to do is add some more platforms and make sure the movement and physics is all fine and hopefully not buggy. So over the next week I'll add some more platforms to test with, add a moving platform, and then potentially look at adding a swinging vine, as that is a game play element I want to have in the game. I've done some basic physics code with springs before, so I'm going to look at using that to do swinging vines with.

So next week I'll cover my progress with that, and possibly look at doing a super early pre alpha game play video to go with the milestone. Also spoke to one of my artists today, and hopefully I should also have some new art to show off next week as well.

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!

****
Please log in or register to reply.
Live Events Refresh
Next event in 1h 14m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft808
Nina 256
ProTech54
StarCraft: Brood War
Sea 3916
Hyuk 3117
Larva 707
Backho 365
Hyun 198
zelot 109
scan(afreeca) 73
sSak 45
Mind 10
Sacsri 10
[ Show more ]
IntoTheRainbow 7
Dota 2
XcaliburYe319
League of Legends
JimRising 634
Counter-Strike
Stewie2K735
Heroes of the Storm
Khaldor230
Other Games
SortOf110
Organizations
Other Games
gamesdonequick1355
StarCraft: Brood War
lovetv 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Berry_CruncH268
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota2156
Upcoming Events
FEL
1h 14m
Krystianer vs sOs
SKillous vs ArT
MaNa vs Elazer
Spirit vs Gerald
Clem vs TBD
uThermal vs TBD
Reynor vs TBD
Lambo vs TBD
BSL20 Non-Korean Champi…
6h 14m
BSL20 Non-Korean Champi…
10h 14m
Bonyth vs Zhanhun
Dewalt vs Mihu
Hawk vs Sziky
Sziky vs QiaoGege
Mihu vs Hawk
Zhanhun vs Dewalt
Fengzi vs Bonyth
Sparkling Tuna Cup
2 days
WardiTV European League
2 days
Online Event
2 days
uThermal 2v2 Circuit
3 days
The PondCast
4 days
Replay Cast
4 days
Korean StarCraft League
5 days
[ Show More ]
CranKy Ducklings
6 days
Liquipedia Results

Completed

CSLPRO Last Chance 2025
Esports World Cup 2025
Murky Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL 20 Non-Korean Championship
BSL 20 Team Wars
FEL Cracov 2025
CC Div. A S7
Underdog Cup #2
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25

Upcoming

ASL Season 20: Qualifier #1
ASL Season 20: Qualifier #2
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
HCC Europe
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.