This file contains hidden or 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
| local storyboard = require ("storyboard") --import storyboard | |
| local scene = storyboard.newScene() --create a new scene | |
| function scene:createScene(event) --create your objects here | |
| local group = self.view --In scene's view, we'll add(insert) our display objects | |
| time = 3 -- count down from 3 | |
| --Text will be displayed when time is up! | |
| gogogo = display.newText("Go go go!", 0, 0, "James Fajardo", 100) |
This file contains hidden or 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
| --CountDown App 2 | |
| W=display.contentWidth/2 | |
| H=display.contentHeight/2 | |
| local time = 3 -- count down from 3 | |
| local gogogo = display.newText("Go go go!", 0, 0, "James Fajardo", 100) | |
| gogogo.alpha=0 --is not visible | |
| gogogo.x=W | |
| gogogo.y=H | |
| local timeSound=audio.loadSound("button.wav") |
This file contains hidden or 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
| --Countdown App | |
| --os.time() returns the current number of seconds since Jan 1, 1970 to current time | |
| local start=os.time() | |
| local background = display.newImage("background.png") | |
| local W=display.contentWidth | |
| local H=display.contentHeight | |
| --timeIsUp is shown after time is Up, haha | |
| local timeIsUp=display.newText("Time is Up!", 0,0, "James Fajardo", 100) | |
| timeIsUp.x=W/2 |
This file contains hidden or 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
| --Disco App =) | |
| --Create a rectangular object that covers the entire screen | |
| disco = display.newRect(0,0, display.contentWidth, display.contentHeight) | |
| --Play Disco music | |
| media.playSound("whatislove.wav") | |
| local function changeColor() | |
| --Changes the color of "disco" rectangular object randomly in every frame | |
| disco:setFillColor(math.random(0,255),math.random(0,255), math.random(0,255)) |
This file contains hidden or 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
| local advice = display.newText("Take a Walk", 0, 0, "James Fajardo", 70) | |
| advice: setReferencePoint ( display.CenterReferencePoint ) | |
| _W=display.contentWidth | |
| _H=display.contentHeight | |
| advice.x=_W/2 | |
| advice.y=_H/2 | |
| adviceBox={"Take a Walk", "Choose to Be Happy", "Listen", "Care About Beloved Ones", "Smile", "Listen Good Music", "Don't Give Up", "Imagine" } |
This file contains hidden or 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
| --James Fajardo is the name of the font that I am using | |
| local advice = display.newText("Take a Walk", 0, 0, "James Fajardo", 70) | |
| --while placing the "advice" display object, regard its center point as a reference | |
| advice: setReferencePoint ( display.CenterReferencePoint ) | |
| _W=display.contentWidth --screen's width | |
| _H=display.contentHeight --screen's height | |
| --place the center x and y of the "advice" object to specified points below. | |
| advice.x=_W/2 |
This file contains hidden or 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
| package edu.iyte.ceng316.view; | |
| import java.io.*; | |
| import java.net.URL; | |
| import javax.sound.sampled.*; | |
| public enum SoundEffect { | |
| HIT("/edu/iyte/ceng316/resource/hit.wav"), | |
| MISS("/edu/iyte/ceng316/resource/miss.wav"), | |
| BG("/edu/iyte/ceng316/resource/background.wav"), | |
| CONGRATS("/edu/iyte/ceng316/resource/congrats.wav"); |
This file contains hidden or 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
| def adj(g): | |
| """ | |
| Convert a directed graph to an adjaceny matrix. | |
| >>> g = {1: {2: 3, 3: 8, 5: -4}, 2: {4: 1, 5: 7}, 3: {2: 4}, 4: {1: 2, 3: -5}, 5: {4: 6}} | |
| >>> adj(g) | |
| {1: {1: 0, 2: 3, 3: 8, 4: inf, 5: -4}, 2: {1: inf, 2: 0, 3: inf, 4: 1, 5: 7}, 3: {1: inf, 2: 4, 3: 0, 4: inf, 5: inf}, 4: {1: 2, 2: inf, 3: -5, 4: 0, 5: inf}, 5: {1: inf, 2: inf, 3: inf, 4: 6, 5: 0}} | |
| """ | |
| vertices = g.keys() | |
| dist = {} |
This file contains hidden or 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
| import java.awt.Color; | |
| import java.awt.Graphics; | |
| import java.awt.event.ActionEvent; | |
| import java.awt.event.ActionListener; | |
| import javax.swing.JFrame; | |
| import javax.swing.JPanel; | |
| import javax.swing.Timer; | |
| public class MyGUI extends JPanel implements ActionListener | |
| { |
This file contains hidden or 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
| /*1. JPanel has an opaque property. | |
| 2. By default it is true. | |
| 3. JPanel's paintComponent method contains the code the draws the background color, when it is opaque. | |
| 4. When you subclass JPanel and override paintComponent, it's up to you to remember to call super.paintComponent; if you don't call the code it wouldn't be called otherwise. | |
| 5. That's it. "Losing opaqueness" should really be thought of as "subclassing and making a mistake. | |
| */ | |
| import java.awt.Color; | |
| import java.awt.Graphics; | |
| import java.awt.event.ActionEvent; |