• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 19:34
CEST 01:34
KST 08:34
  • 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 20252Power Rank - Esports World Cup 202575RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15HomeStory Cup 27 - Info & Preview18
Community News
Google Play ASL (Season 20) Announced15BSL 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
What tournaments are world championships? #1: Maru - Greatest Players of All Time Tournament Spotlight: FEL Cracow 2025 Power Rank - Esports World Cup 2025 I offer completely free coaching services
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
Google Play ASL (Season 20) Announced Flash Announces (and Retracts) Hiatus From ASL BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ 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
[G] Mineral Boosting Does 1 second matter in StarCraft? Simple Questions, Simple Answers
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
US Politics Mega-thread UK 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
Formula 1 Discussion 2024 - 2025 Football Thread 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: 621 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
BSL20 Non-Korean Champi…
18:00
RO8 Round Robin Group - Day 3
Bonyth vs Sziky
Dewalt vs Hawk
Hawk vs QiaoGege
Sziky vs Dewalt
Mihu vs Bonyth
Zhanhun vs QiaoGege
QiaoGege vs Fengzi
ZZZero.O172
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 156
StarCraft: Brood War
ZZZero.O 172
Aegong 104
Zeus 66
HiyA 39
NaDa 26
JulyZerg 13
Dota 2
monkeys_forever1078
League of Legends
Grubby4480
febbydoto6
Counter-Strike
fl0m2646
flusha396
Super Smash Bros
hungrybox1661
Mew2King269
Heroes of the Storm
Khaldor206
Other Games
tarik_tv21153
gofns12550
FrodaN2154
shahzam368
JimRising 361
ViBE73
Organizations
Other Games
gamesdonequick2156
BasetradeTV23
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• StrangeGG 56
• musti20045 50
• HeavenSC 31
• Kozan
• AfreecaTV YouTube
• intothetv
• sooper7s
• IndyKCrew
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• HerbMon 20
• FirePhoenix4
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22507
League of Legends
• Doublelift5365
Other Games
• imaqtpie1252
Upcoming Events
FEL
9h 26m
BSL20 Non-Korean Champi…
14h 26m
BSL20 Non-Korean Champi…
18h 26m
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
Online Event
2 days
uThermal 2v2 Circuit
3 days
The PondCast
4 days
Replay Cast
5 days
Korean StarCraft League
6 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

CSL Xiamen Invitational
Esports World Cup 2025
Murky Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL20 Non-Korean Championship
BSL Team Wars
CSLPRO Last Chance 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
FEL Cracov 2025
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.