Skip to content

Instantly share code, notes, and snippets.

View Lukehill24003's full-sized avatar

Lukehill24003

View GitHub Profile
if player collides
check if collision is object,x,y,z
if
object x - -5 from life
object y - -10 from life
object z - - 15 from life
if players health <0 player loses
pseudocode for pickups
when gameobject 'player' collides with object, check if object is wall or ammo
if collision is with ammo, check if players ammo = >10
if ammo is = >10, de activate gameobject 'ammo' and change ammo to 10
respawn gameobject ' ammo' 15 seconds after de activation
@Lukehill24003
Lukehill24003 / gist:443835a5fb879e01e020ca1e8623396a
Created October 24, 2019 21:54
pseudocode for instantiation
psuedocode for instantiation
check if player has ammo, when player has 'x'amount of bullets, allow 'x' amount of shots
when key 'ctrl' is pressed spawn gameobject 'bullet' at gameobject 'spawn' transfrom postion
when bullet has been spawned, apply force 'speed = x'
if bullet collides with gameobject ' target' set 'target' to unactive
when all targets are unactive display message "you win"
pseudocode for player movemnt
when key 'd' is pressed, apply force in direction 'right'
when movement = 'right' play animation ' right movement'
when key 'a' is pressed, apply force in direction 'left'
when movement = 'left' play animation 'left movement
/* if user presses fire button
* Create copy of bullet template
* Spawn the bullet at firing point
* move the bullet using physics relative to the player
*/
/*
* Bullet variable
* Fire point variable
* Bullet speed variable
*/
public class PlayerController : MonoBehaviour
{
private float flyingSpeed = 300f;
private float rotationSpeed = 50f;
private Rigidbody2D rb2d;
private bool canBoost = false;
private float boostAmount = 5f;
void Start()
private void Update()
{
if (Input.GetButtonDown("Jump") && onGround)
{
jump = true;
}
}
void FixedUpdate()
{
void Update()
{
if(Input.GetKeyDown(KeyCode.Q))
{
GetComponent<SpriteRenderer>().color = Color.blue;
}
}
}
public class CameraController : MonoBehaviour
{
public GameObject Player;
private Vector3 offset;
// Start is called before the first frame update
void Start()
{
public class PlayerController : MonoBehaviour
{
public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();