• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:09
CEST 02:09
KST 09:09
  • 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: Turbulence9Classic 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 cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly 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 Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris SC4ALL $6,000 Open LAN in Philadelphia Sparkling Tuna Cup - Weekly Open Tournament WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
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
BW General Discussion [ASL20] Ro16 Preview Pt2: Turbulence ASL20 General Discussion Diplomacy, Cosmonarchy Edition BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread 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
Things Aren’t Peaceful in Palestine US Politics Mega-thread 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: 1266 users

Student Game Dev Part 17 - Video!

Blogs > Soan
Post a Reply
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
March 21 2014 00:18 GMT
#1
+ Show Spoiler [Previous parts] +
Part One - It begins
Part Two - Technical Foundation
Part Three - Game Design
Part Four - Input and Physics
Part Five - More Physics Things
Part Six - Even More Physics
Part Seven - User Interface
Part Eight - UI and the Editor
Part Nine - Editor Progress
Part Ten - Progress, and videos
Part Eleven - Fixing the Physics
Part Twelve - Unproductive
Part Thirteen - Context menu + enemies
Part Fourteen - Enemies and Problems
Part Fifteen - Play testing
Part Sixteen - Editor and Art


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. Last week I talked about fixing a couple of smaller issues, working on the editor a bit more, and had some early art of the main character. This week I'll be talking about getting moving platforms to work properly, and have a new video. This video also includes a little bit of actual art!

Moving Platforms
The moving platforms in Sam the Pirate have a very simple design. They move in one direction until they hit a stationary tile, then they turn around and go in the other direction until they hit something else, etc. I had previously implemented this behaviour into the game, although that was before I started work on the editor, so the positioning and size of the platform had been handwritten into the level file, now I was looking to add them to levels through the editor.

This turned out to not be too difficult. Positioning the sprites that make up the moving platform was easy, as it was pretty much the same as what I had already done with positioning regular tiles. Correctly calculating the size of the physics object that would be loaded into the game was not particularly difficult either. Making sure that the position of this physics object matched up with turned out to be a bit trickier, mostly because I forgot parentheses.

As the moving platforms are made up of a set of regular tile sprites, each with their own position, the correct position of the physics object needed to be in the centre. So I had to find the position on the left edge, the position on the right edge, and find the middle. Initially I did it like this:
position = right - left * 0.5 + left

Can you see the problem? Lets enter 100 for right, and 50 for left. The expected answer would be 75, yet you would get 125, because I totally forgot about the order of operations, PEDMAS, or BEDMAS, or however else you may have been taught. Either way, I forgot that any multiplication/division would be done before addition/subtraction, and so the position of the physics object was not matching the location of the sprite, which was were I wanted it to be.

To get the correct result, it needed to look like this:
position = (right - left) * 0.5 + left

I had a bit of a laugh at myself afterwards for forgetting something that should be so simple.

What that fixed, moving platforms placed into the editor loaded correctly, and started going back and forth when I played the game. The player was able to jump on and off the moving platform, however they couldn't run on them. This puzzled me for a while, as all the code for ensuring that the player was moving in tandem with the platform appeared to be working correctly, without preventing the player from moving left or right. Their position even seemed to lag behind the platform slightly, as eventually they would fall off completely.

Finally, I noticed that the game was attempting to make sure the player was moving in tandem with the platform twice, at two different points each frame! The second instance was late enough in the frame to override any player movement, making it look like they couldn't move at all. That piece of code came from when I had first implemented the moving platforms, so once I took that out everything worked just fine, as you can see in the below video!

Video
Can you spot the moon walking zombie pirate?


What's next?
Parallax scrolling is the next big item to implement. Still not entirely sure how I'm going to implement this, or what I'm going to put in there, but I've got some time over the weekend to think about it before I get stuck into it next week.

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! You can also check out the blog, previous posts, screenshots and videos over at my site.

mahrgell
Profile Blog Joined December 2009
Germany3943 Posts
March 21 2014 10:57 GMT
#2
So why do the zombies fall through the moving platforms? Are your platforms racist against zombies and won't carry them?
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
March 21 2014 20:43 GMT
#3
haha, no! I just haven't finished coding them yet. They're not meant to fall off platforms, I just haven't got around to implementing that.
Please log in or register to reply.
Live Events Refresh
PiGosaur Monday
00:00
#49
davetesta55
Liquipedia
OSC
23:00
OSC Elite Rising Star #16
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 124
trigger 26
StarCraft: Brood War
Artosis 754
Backho 135
NaDa 14
Dota 2
monkeys_forever413
Counter-Strike
fl0m831
kRYSTAL_40
Super Smash Bros
C9.Mang0266
Mew2King10
Heroes of the Storm
NeuroSwarm127
Other Games
summit1g8349
Grubby3546
shahzam754
Day[9].tv651
ToD228
Sick159
Maynarde122
Trikslyr61
XaKoH 55
ViBE50
Organizations
Other Games
gamesdonequick627
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota22121
Other Games
• Scarra1178
• imaqtpie865
• Day9tv651
Upcoming Events
LiuLi Cup
10h 51m
OSC
18h 51m
RSL Revival
1d 9h
Maru vs Reynor
Cure vs TriGGeR
The PondCast
1d 12h
RSL Revival
2 days
Zoun vs Classic
Korean StarCraft League
3 days
BSL Open LAN 2025 - War…
3 days
RSL Revival
3 days
BSL Open LAN 2025 - War…
4 days
RSL Revival
4 days
[ Show More ]
Online Event
4 days
Wardi Open
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
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 World Championship of Poland 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.