Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Pham danhp

View GitHub Profile
View whitespace.sh
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Find files with trailing whitespace
View a2.sql
CREATE TABLE Departments
(did INTEGER NOT NULL UNIQUE,
departmentName CHAR(30) NOT NULL,
doctorId INTEGER,
numberOfBeds INTEGER NOT NULL,
PRIMARY KEY (did));
CREATE TABLE Employees
(eid INTEGER NOT NULL UNIQUE,
did INTEGER NOT NULL,
View finalAI.java
package ai;
import mvc.Control;
import spaceracer.*;
public class StudentAIQuestion6 implements Control {
private final Radar myRadar;
private final Spaceship myShip;
private float desiredSpeed;
private float desiredYPos;
View direction.lua
update = function( dt, enemy, player, level )
if enemy.dead then return end
local direction
if enemy.hp < 16 and math.abs(enemy.position.x - player.position.x) < 250 then
enemy.idletime = enemy.idletime + dt
if math.abs(enemy.position.x - player.position.x) < 2 then
--stay put
elseif enemy.position.x < player.position.x then
enemy.direction = 'right'
@danhp
danhp / gist:6651281
Created Sep 21, 2013
Set Correct release sprite
View gist:6651281
function Climbable:release( player )
local state = player.currently_held and 'wielding' or 'default'
player:setSpriteStates(state)
player.isClimbing = false
end
@danhp
danhp / item.lua
Last active Dec 20, 2015
create Item
View item.lua
local Item = require 'items/item'
return{
name = "note",
image = "note",
type = "consumable",
MAX_ITEMS = 1,
use = function( consumable, player )
locl itemNode = require('items/consumables/note')
local item = Item.new(itemNode)
@danhp
danhp / gist:5930987
Created Jul 5, 2013
subracts the item from inventory
View gist:5930987
for i = 1, self.sellAmount do
playerItem, pageIndex, slotIndex = self.player.inventory:search(item)
if self.player.inventory.pages[pageIndex][slotIndex].quantity > 1 then
playerItem.quantity = playerItem.quantity - 1
elseif self.player.inventory.pages[pageIndex][slotIndex].quantity == 1 then
self.player.inventory:removeItem(slotIndex, pageIndex)
end
end