Skip to content

Instantly share code, notes, and snippets.

View danhp's full-sized avatar

Daniel Pham danhp

View GitHub Profile
@danhp
danhp / a2.sql
Created February 23, 2015 22:21
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,
#!/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
@danhp
danhp / gist:5930987
Created July 5, 2013 00:49
subracts the item from inventory
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
@danhp
danhp / item.lua
Last active December 20, 2015 07:29
create Item
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:6651281
Created September 21, 2013 14:43
Set Correct release sprite
function Climbable:release( player )
local state = player.currently_held and 'wielding' or 'default'
player:setSpriteStates(state)
player.isClimbing = false
end
@danhp
danhp / direction.lua
Created November 17, 2013 04:49
Mariachi
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'
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;