Skip to content

Instantly share code, notes, and snippets.

@ohiofi
ohiofi / Start passage
Created November 25, 2015 15:38
Twine v1 Screen Shake Effect
<<screenShake 1400>>
"EARTHQUAKE!!!" You yell. No one answers. The shaking seems to have stopped.
/* The number 1400 is the amount of time (in milliseconds) that the screen will shake */
@ohiofi
ohiofi / screenShake README.md
Last active November 25, 2015 16:26 — forked from dariusk/README.md
Twine screenShake macro

This Twine version 1 macro lets you make the screen shake! Tested in Chrome and Firefox. Should work in Opera and IE 10+. Uses CSS3 animations, taken from this CSS Reset tutorial.

See a demo in action here.

How to set it up

IMPORTANT NOTE: Due to a bug in Twine 1.3.5, macros did not work on the Start passage. This issue has been fixed in Twine 1.4.1.

  • Paste the contents of the stylesheet.css file below into a new passage. Call the passage whatever you want, and add the tag "stylesheet" to it.
  • Paste the contents of the script.js file below into a new passage. Call the passage whatever you want, and add the tag "script" to it.
@ohiofi
ohiofi / playSound README
Last active November 25, 2015 16:40
playSound Macro for Twine v1
Audio macro for Twine version 1
Not sure where I found this code, sorry. Will give proper credit when I figure it out.
<<playsound "sfx1.mp3">>
Use playsound to simply play a sound once.
<<loopsound "track1.mp3">><<loopsound "track2.mp3">><<loopsound "track3.mp3">>
Use loopsound to loop background music.
You can split it into tracks, like bass, guitar, drums. If the tracks are the same length, they will remain in sync.
@ohiofi
ohiofi / hideTwineBackArrow.css
Last active November 5, 2016 22:23
Hide the Back Arrow in Twine
tw-sidebar {
display:none; /* Hide the undo and redo buttons */
}
@ohiofi
ohiofi / textinputbootstrap.html
Created January 18, 2018 14:39
Read-only text input form with Use button for JS with classes for Bootstrap
<label for="text">Your Backpack:</label><br>
<div class="input-group">
<input type="text" class="form-control input-lg" id="backpack" placeholder="none" readonly>
<div class="input-group-btn">
<button class="btn btn-default btn-lg" type="button" id="useItem" onclick="useItem(document.getElementById('backpack').value)">Use</button>
</div>
</div>
@ohiofi
ohiofi / CookieStuff.js
Created February 1, 2018 15:32
cookie stuff
//Cookie stuff
function setCookie(variablename, variablevalue, exdays) {
var expiredate = new Date();
expiredate.setTime(expiredate.getTime() + (exdays* 24 * 60 * 60 * 1000));
var expires = "expires="+expiredate.toUTCString();
document.cookie = variablename + "=" + variablevalue + ";"+ expires + ";path=/";
console.log(document.cookie);
}
function getCookie(searchVariable) {
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);
}
[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> ();
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;
}