Skip to content

Instantly share code, notes, and snippets.

View jquave's full-sized avatar
✔️
jquave

Jameson Quave jquave

✔️
jquave
View GitHub Profile
// For animation
bool aDucking = false;
if(input.directionalPad.y<0) aDucking = true;
float runSprintTransitionDelay = 1.20f;
float aWalkSpeed=Mathf.Abs(rigidbody2D.velocity.x);
if(isGrounded) {
if(aWalkSpeed>0.1f) {
if(currentAnimation=="CrowRun" && (lastSwitchedAnimation+runSprintTransitionDelay)<Time.time) {
BEFORE
else {
if(currentAnimation=="CrowJumpForward" || currentAnimation=="CrowJumpForward_IntoIdle") {
//ChangeAnimation("CrowJumpForward_IntoIdle");
}
else if(currentAnimation=="CrowSprint" || currentAnimation=="CrowStop") {
//If the player stops pressing all keys while in CrowSprint, play CrowStop. (If in CrowRun, just go back to idle, they dont have enough momentum to slide.)
ChangeAnimation("CrowStop");
}
BEFORE
else {
if(currentAnimation=="CrowJumpForward" || currentAnimation=="CrowJumpForward_IntoIdle") {
//ChangeAnimation("CrowJumpForward_IntoIdle");
}
else if(currentAnimation=="CrowSprint" || currentAnimation=="CrowStop") {
//If the player stops pressing all keys while in CrowSprint, play CrowStop. (If in CrowRun, just go back to idle, they dont have enough momentum to slide.)
ChangeAnimation("CrowStop");
}
switch (currentAnimation) {
// Runs
case "CrowRun":
if(player.jumping)
ChangeAnimation("CrowJumpForward");
else if(player.sliding)
ChangeAnimation("CrowStop");
else if(atMaxSpeed) {
// Player is at max speed, switch to sprint after 1 second
## Runs
CrowRun:
CrowJumpUpward
CrowStop
CrowSprint
CrowIdle
---
CrowSprint:
CrowJumpForward
CrowStop
using UnityEngine;
using System.Collections;
public class PlayerSettings : MonoBehaviour {
// Player settings
public float slideTime = 0.5f;
public float walkSpeed = 2.0f;
public float maxWalkSpeed = 4.0f;
public float initialJumpSpeed = 5.5f;
using UnityEngine;
using System.Collections;
public class Checkpoint : MonoBehaviour {
void OnTriggerEnter2D(Collider2D col)
{
Player p = col.GetComponent<Player>();
if( p != null) {
// Player touched pickup
public void SpawnVehicles() {
// Spawn between 3 and 6 vehicles
float carWidth = 10.0f;
for(int i=0;i<Random.Range(3,6);i++) {
Vector3 vPos = playerTransform.position;
vPos += (40.0f*i+40.0f)*Vector3.forward;
//float laneStartX = xStart;
float rx = Random.Range(xStart + carWidth, xStart+levelWidth - carWidth);
GameObject vehicle = (GameObject)Instantiate(vehiclePrefab, vPos, Quaternion.Euler(0,180,0));
Runner tRunner = vehicle.GetComponent<Runner>();
Level 1:
Endless-runner like with open area at end
Level 2:
I drifted deeper in to sleep.
Green background, tree lines.
Level 3:
The dream world grew more abstract and strange.
Floating beds, trees, colorful background.
class Command
attr_accessor :name, :response, :needs_arg
def initialize args
needs_arg = false # Default
args.each do |k,v|
instance_variable_set("@#{k}", v) unless v.nil?
end
puts 'Command added: '+name