#100DaysOfCode#100DaysOfGameDevC#CodingGame DevIllogical BaconTrainingUnity

Flappy Pig – Obstacles, Score & Parallax

Day 077 #100DaysOfCode
Day 041 #100DaysOfGameDev

  • place Wooden Post object and set to midground sorting layer
  • give BoxCollider2D component to Wooden Post
  • duplicate Wooden Post object to create a top and a bottom version
  • group posts inside holder object
  • assign BoxCollider2D component to Post holder object and set as trigger
  • set trigger zone for Posts after gap in Wooden Posts to create a scoring zone
  • add RigidBody2D component to Post holder and set to kinematic
  • create new WoodenPosts script and add to Post holder object
WoodenPosts script
  • add new public PigScored function to GameControl script
new PigScored function in GameControl
  • create private Score integer in GameControl
  • create state in PigScored that disallows scoring if Pig is KO’d
  • create score +1 condition for each set of Posts cleared
  • add namespace UnityEngine.UI to GameControl to be able to allow UI score updating
  • declare new public Text named scoreText to track scoring
  • create score overlay to display on-screen within PigScored function
Score updating in Flappy Pig
  • in WoodenPosts script set trigger condition to check if collision entity is FlappyPig and call PigScored if true
  • add ScrollingObject script to Posts
  • turn Posts into a prefab for use in repeating obstacles
  • created ParallaxRepeat script for sky background
ParallaxRepeat script
  • created ParallaxScroll script for sky background
ParallaxScroll script
  • separated Sky background from Ground and attached new Parallax scripts to it
  • set new parallaxScroll speed for new Sky background velocity in GameControl
parallaxSpeed control setting in GameControl
Obstacles and Scoring proof-of-concept
Parallax scrolling

Leave a Reply

Your email address will not be published. Required fields are marked *