This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Mr. Riley's Wall class v1.20200207 | |
2/07/20 | |
How to use this Wall class | |
1) from wall import * | |
2) Instanciate the screen. Like this: | |
screen = Screen() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global abs,angleMode,append,background,beginShape,bezier,box,camera,ceil,CENTER,color,cone,cos,createCanvas,createCanvas,createGraphics,curveVertex,cylinder,DEGREES,displayHeight,displayWidth,dist,div,DOWN_ARROW,ellipse,endShape,fill,floor,frameCount,frameRate,height,image,key,keyCode,keyIsDown,keyIsPressed,keyIsPressed,keyPressed,LEFT,LEFT_ARROW,lerpColor,line,loadImage,loadJSON,loadSound,map,mouseIsPressed,mouseX,mouseY,noFill,noLoop,normalMaterial,noStroke,p5,plane,point,pointLight,pop,push,push,RADIANS,radians,random,rect,resizeCanvas,resizeCanvas,RIGHT,RIGHT_ARROW,rotate,rotateX,rotateY,rotateZ,round,round,scale,shuffle,sin,sphere,stroke,strokeWeight,text,textAlign,textFont,textSize,texture,textWidth,torus,translate,triangle,UP_ARROW,WEBGL,width,windowHeight,windowHeight,windowWidth,world */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (cameraTarget != null) | |
{ | |
var newPos = Vector2.Lerp (transform.position, cameraTarget.position, Time.deltaTime * trackingSpeed); | |
var camPos = new Vector3 (newPos.x, newPos.y, -10f); | |
var v3 = camPos; | |
var clampX = Mathf.Clamp (v3.x, minX, maxX); | |
var clampY = Mathf.Clamp (v3.y, minY, maxY); | |
transform.position = new Vector3 (clampX, clampY, -10f); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RequireComponent(typeof(SpriteRenderer),typeof(Rigidbody2D),typeof(Animator))] | |
public float speed = 14f; | |
public float accel = 6f; | |
private Vector2 input; | |
private SpriteRenderer sr; | |
private Rigidbody2D rb; | |
private Animator animator; | |
sr = GetComponent<SpriteRenderer> (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Truth Table Generator | |
# Complete the seven ### comments so that 50% of the time it | |
# adds the first option and 50% of the time it adds the second | |
from random import * | |
while True: | |
outputString = "(" | |
# True / False | |
if random() >= 0.5: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool PlayerIsOnGround(){ | |
bool groundCheck1 = Physics2D.Raycast (new Vector2 (transform.position.x, transform.position.y - height), -Vector2.up, rayCastLengthCheck); | |
bool groundCheck2 = Physics2D.Raycast (new Vector2 (transform.position.x + (width - 0.2f), transform.position.y - height), -Vector2.up, rayCastLengthCheck); | |
bool groundCheck3 = Physics2D.Raycast (new Vector2 (transform.position.x - (width - 0.2f), transform.position.y - height), -Vector2.up, rayCastLengthCheck); | |
if (groundCheck1 || groundCheck2 || groundCheck3) | |
return true; | |
else | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int GetWallDirection(){ | |
bool isWallLeft = Physics2D.Raycast (new Vector2 (transform.position.x - width, transform.position.y), -Vector2.right, rayCastLengthCheck); | |
bool isWallRight = Physics2D.Raycast (new Vector2 (transform.position.x + width, transform.position.y), Vector2.right, rayCastLengthCheck); | |
if (isWallLeft) | |
return -1; | |
else if(isWallRight) | |
return 1; | |
else | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool IsWallToLeftOrRight(){ | |
bool wallOnLeft = Physics2D.Raycast (new Vector2 (transform.position.x - width, transform.position.y), -Vector2.right, rayCastLengthCheck); | |
bool wallOnRight = Physics2D.Raycast (new Vector2 (transform.position.x + width, transform.position.y), Vector2.right, rayCastLengthCheck); | |
if (wallOnLeft || wallOnRight) | |
return true; | |
else | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnCollisionEnter2D(Collision2D coll){ | |
if (coll.transform.tag == "Player") { | |
var audioSource = GetComponent<AudioSource> (); | |
if (audioSource != null) { | |
audioSource.PlayOneShot (deathClip); | |
} | |
Instantiate(playerDeathPrefab, coll.contacts[0].point, Quaternion.identity); | |
sr.sprite = hitSprite; | |
//Destroy(coll.gameObject) | |
//GameManager.instance.RestartLevel (1.25f); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class byteOverflow { | |
public static void main(String[] args) { | |
//System.out.println(Byte.MAX_VALUE); | |
//System.out.println(Byte.MIN_VALUE); | |
byte foo = 127; | |
foo++; | |
System.out.println(foo); | |
} |