Skip to content

Instantly share code, notes, and snippets.

View figengungor's full-sized avatar

Figen Güngör figengungor

View GitHub Profile
@figengungor
figengungor / gist:5774390
Last active December 18, 2015 11:18
scene1
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)
@figengungor
figengungor / gist:5745882
Last active December 18, 2015 07:19
Countdown App 2, with timer.performWithDelay() and transition.to()
--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")
@figengungor
figengungor / gist:5745676
Created June 9, 2013 23:17
Countdown App 1, using os.time() and transition.to()
--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
@figengungor
figengungor / gist:5743438
Created June 9, 2013 13:04
EnterFrame Event in Corona
--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))
@figengungor
figengungor / gist:5718016
Last active December 18, 2015 03:28
Advice Code Utilized. (Elements do no repeat untill all elements in the table are displayed)
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" }
@figengungor
figengungor / gist:5717493
Last active December 18, 2015 03:19
Displaying Objects, Adding Sound, Using Tables and Event Listener in Corona SDK
--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
@figengungor
figengungor / gist:5673813
Created May 29, 2013 21:02
Sound Effect for a Game in Java
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");
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 = {}
@figengungor
figengungor / gist:5145437
Last active December 14, 2015 20:39
Java GUI >> Basic Animation (bounce back logic added)
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
{
@figengungor
figengungor / gist:5145290
Created March 12, 2013 18:02
Java GUI >> Basic Animation 2 (super.paintComponent(), repaint())
/*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;