• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:24
CEST 23:24
KST 06: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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence5Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
Weekly Cups (Sept 8-14): herO & MaxPax split cups3WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia7Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29LiuLi Cup - September 2025 Tournaments3
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues
Tourneys
WardiTV TL Team Map Contest #5 Tournaments Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
[ASL20] Ro16 Preview Pt2: Turbulence BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ ASL20 General Discussion Playing StarCraft as 2 people on the same network
Tourneys
Is there English video for group selection for ASL [ASL20] Ro16 Group C [ASL20] Ro16 Group B [IPSL] ISPL Season 1 Winter Qualis and Info!
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile General RTS Discussion Thread Nintendo Switch Thread Borderlands 3
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread The Big Programming Thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1432 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 2h 36m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ZombieGrub234
NeuroSwarm 152
SteadfastSC 143
UpATreeSC 118
JuggernautJason64
Lillekanin 14
StarCraft: Brood War
Shuttle 703
ajuk12(nOOB) 20
sSak 18
Dota 2
Fuzer 172
LuMiX1
Counter-Strike
pashabiceps675
Foxcn397
Stewie2K300
Super Smash Bros
PPMD67
Heroes of the Storm
Liquid`Hasu534
Other Games
FrodaN4253
Grubby4029
summit1g1688
shahzam300
mouzStarbuck266
ToD133
C9.Mang0126
SortOf72
Trikslyr65
rGuardiaN35
Nathanias7
fpsfer 2
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• davetesta29
• sitaska14
• RyuSc2 13
• Psz 9
• IndyKCrew
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• LaughNgamezSOOP
StarCraft: Brood War
• RayReign 29
• FirePhoenix11
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2923
• masondota22192
• Ler97
League of Legends
• TFBlade468
Other Games
• Scarra1312
• imaqtpie1026
Upcoming Events
OSC
2h 36m
Sparkling Tuna Cup
12h 36m
Afreeca Starleague
12h 36m
Light vs Speed
Larva vs Soma
2v2
13h 36m
PiGosaur Monday
1d 2h
LiuLi Cup
1d 13h
RSL Revival
2 days
Maru vs Reynor
Cure vs TriGGeR
The PondCast
2 days
RSL Revival
3 days
Zoun vs Classic
Korean StarCraft League
4 days
[ Show More ]
RSL Revival
4 days
[BSL 2025] Weekly
4 days
BSL Team Wars
4 days
RSL Revival
5 days
Online Event
5 days
Wardi Open
6 days
Liquipedia Results

Completed

BSL 20 Team Wars
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL Polish World Championship 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
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.