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
//These are declared outside the method, but in the class. | |
/**Ball velocity*/ | |
private double vx, vy; | |
/**Random number generator for vx*/ | |
private RandomGenerator rgen = RandomGenerator.getInstance(); | |
/** Animation delay or paust time between ball moves */ | |
private static final int DELAY = 10; |
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 moveBall() { | |
ball.move(vx, vy); | |
//check for walls | |
//need to get vx and vy at the point closest to 0 or the other edge | |
if ((ball.getX() - vx <= 0 && vx < 0 )|| (ball.getX() + vx >= (getWidth() - BALL_RADIUS*2) && vx>0)) { | |
vx = -vx; | |
} | |
//We don't need to check for the bottom wall, since the ball can fall through the wall at that point | |
if ((ball.getY() - vy <= 0 && vy < 0 )) { | |
vy = -vy; |
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 (collider == paddle) { | |
/* We need to make sure that the ball only bounces off the top part of the paddle | |
* and also that it doesn't "stick" to it if different sides of the ball hit the paddle quickly and get the ball "stuck" on the paddle. | |
* I ran "println ("vx: " + vx + ", vy: " + vy + ", ballX: " + ball.getX() + ", ballY: " +ball.getY());" | |
* and found that the ball.getY() changes by 4 every time, instead of 1, | |
* so it never reaches exactly the the height at which the ball hits the paddle (paddle height + ball height), | |
* therefore, I estimate the point to be greater or equal to the height at which the ball hits the paddle, | |
* but less than the height where the ball hits the paddle minus 4. | |
*/ | |
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
/* | |
* File: HangmanLexicon.java | |
* ------------------------- | |
* This file contains a stub implementation of the HangmanLexicon | |
* class that you will reimplement for Part III of the assignment. | |
*/ | |
import acm.util.*; | |
import java.io.*; | |
import java.util.*; |
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
/* Pre-condition: The player has finished rolling the dice and selects a category. | |
* This method returns true if the selected category matches | |
* to the actual category correctly, and false if it does not match. */ | |
private boolean checkCategory(int[] dice, int category) { | |
boolean categoryMatch = false; | |
if(category >= ONES && category <= SIXES || category == CHANCE) { | |
categoryMatch = true; | |
} | |
else { | |
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
require 'time' | |
#convert today's time to a string | |
today = Time.now.to_s # => "Mon Dec 12 10:52:45 -0800 2011" | |
#replace the hours:minutes:seconds and time-zone to the time and time zone that you need | |
today[11, 14] = "00:00:00 +0000" # => "Mon Dec 12 00:00:00 +0000 2011" | |
#convert the time string back into time format | |
Time.parse(today) # => Sun Dec 11 16:00:00 -0800 2011 - The time is adjusted for my time-zone (-0800), but it is equivalent to midnight in GMT time (Mon Dec 12 00:00:00 +0000 2011) |
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
<script> | |
var english = { | |
house: "A building for human habitation", | |
tree:"A woody perennial plant", | |
street: "A public road in a city or town" | |
}; | |
var americanEnglish = Object.create(english, { | |
elevator: "A platform or compartment housed in a shaft for raising and lowering people or things to different floors or levels", |
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
#https://dev.twitter.com/docs/api/1/get/search | |
require 'Typhoeus' | |
require 'JSON' | |
url = 'http://api.twitter.com/search.json?q=dev+bootcamp&rpp=5&include_entities=true&result_type=mixed' | |
response = Typhoeus::Request.get(url) | |
p all_tweets = JSON.parse(response.body) |
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
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> | |
<script type=text/javascript src="/game.js"></script> | |
<meta charset="UTF-8"> | |
<link rel="stylesheet" href="game.css"> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
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
development: | |
adapter: postgresql | |
encoding: unicode | |
database: url_development | |
pool: 5 | |
username: jd | |
password: | |
host: localhost | |
port: 5432 | |