DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets

  • submit to reddit

Recent Snippets

                    require 'koala' # gem install koala --no-document

# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "read_mailbox" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxx'
graph = Koala::Facebook::API.new(oauth_access_token)

# get all latest messages
limit = 10
threads = {}
page = graph.get_connections('me','inbox')
begin
	page.each do |thread| 
		threads[thread["id"]] = thread["to"]["data"].map {|x| x['name']}.join ' - '
	end
end while page = page.next_page and threads.length<limit

# ask user which one to download
threads.each { |id, to| puts "id: #{id} : between : #{to}" }
print 'What is the ID of the thread you want to download ? : '
id = gets.chomp

messages = [] # hold messages here
page = graph.get_connections id,'comments'
begin 
	begin
		page.reverse.each do |comment|
			messages.unshift "#{comment['from']['name']} [#{comment['created_time']}]: #{comment['message']}"
		end
	end while page = page.next_page

	oldest_msg = graph.get_object(id) # get the first message between you two
	messages.unshift "#{oldest_msg['from']['name']} : #{oldest_msg['message']}"

rescue Exception => e
	puts "Error : #{e}, and proceeded to write results to far."
end

File.write '/Users/blaze/Desktop/log.txt', messages.join("\n")                 
                    #!/usr/bin/env ruby
require 'koala' # gem install koala --no-document

# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "user_likes" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
graph = Koala::Facebook::API.new(oauth_access_token)

# get all likes
likes = []
page = graph.get_connections('me','likes')
begin
	likes += page
end while page = page.next_page


# print them all then print total likes
likes.each do |l|
	puts "#{l['name']} - http://www.facebook.com/#{l['id']} - #{l['created_time']}"
end
puts "Total likes : #{likes.length}"                
                    #!/usr/bin/env ruby
require 'koala' # gem install koala --no-document
require 'psych'
# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "user_groups" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
group_name = 'Egyptian Geeks'
posts_limit = 100
graph = Koala::Facebook::API.new(oauth_access_token)

# getting groups of interest
group = graph.get_connections('me', 'groups').find { |g| g['name']==group_name }
raise Exception.new 'Group Not found' unless group

# get posts
posts = []
page = graph.get_connections(group['id'],'feed')
begin
	posts += page
end while page = page.next_page and posts.length<=posts_limit

# generate analytics
analytics = posts.inject({}) do |mem, post|
	if mem.keys.include? post['from']['name']
		mem[post['from']['name']] += 1
	else
		mem[post['from']['name']] = 1
	end
	mem
end

# sort descending and convert each to key => value again
sorted = analytics.sort_by { |k,v| -v }.map {|k,v| {k => v}}
puts sorted.to_yaml                
                    #!/usr/bin/env ruby
require 'gosu' # gem install gosu --no-document
include Gosu

$dimension, $splits = 200, 20
$size = $dimension.to_f / $splits.to_f

class Worm
  attr_writer :dir
  def initialize() reset end
  def reset
    @parts = [[0,0],[1,0],[2,0]]
    @dir, @dir_matrix = KbRight, { KbUp=>[0,-1], KbDown=>[0,1],KbRight=>[1,0], KbLeft=>[-1,0] }
    generate_food
  end
  def generate_food() @food = [rand($splits),rand($splits)] end
  def update
    part = [@parts[-1][0]+@dir_matrix[@dir][0], @parts[-1][1]+@dir_matrix[@dir][1]]
	@food!=part ? @parts.shift : generate_food
	if part[0]*part[1]<0 or part[0]>$splits or part[1]>$splits or @parts.include?(part)
		reset
	else
		@parts.push part
	end
  end
  def draw_split win, split
	win.draw_quad split[0]*$size, split[1]*$size, Color::GREEN,
                  split[0]*$size+$size, split[1]*$size, Color::GREEN,
                  split[0]*$size+$size, split[1]*$size+$size, Color::GREEN,
                  split[0]*$size, split[1]*$size+$size, Color::GREEN
  end 
  def draw win
  	draw_split win, @food
  	@parts.each { |split| draw_split win, split }
  end
end

class GameWindow < Window
  def initialize
    super $dimension, $dimension, false, 100
    self.caption = "Worm Game"
    @worm = Worm.new
  end
  def button_down(key) @worm.dir = key if [KbDown,KbUp,KbRight,KbLeft].include? key end
  def update() @worm.update end
  def draw() @worm.draw self end
end
GameWindow.new.show                
                    #!/usr/bin/env ruby
require 'koala' # gem install koala --no-document
require 'json'
# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "user_friends" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxx'

graph = Koala::Facebook::API.new(oauth_access_token)
fields = 'bio,name,birthday,first_name,last_name,gender,hometown,relationship_status,username,website,languages'

friends = []
# getting groups of interest
page = graph.get_connections("me", "friends/?fields=#{fields}")
begin
	friends += page
end while page = page.next_page

# write data to file as json
File.write 'friends.json', friends.to_json                
                    #!/usr/bin/env ruby
require 'gosu' # gem install gosu
$dimension, $squares = 200, 20
$size = $dimension / $squares
class Entity
  def initialize(x,y, win)
    @pos = {x:$dimension/$squares*x, y:$dimension/$squares*y}
    @last_update = @update_limit = 4
    @color = {h:360/$squares.to_f*x, s:1/$squares.to_f*y}
    @color_dir = {h:360/$squares.to_f,s:1/$squares.to_f}
    @shift = {x:x,y:y}
  end
  def update
  	@last_update -= 1
  	if @last_update==0
  		@color_dir[:h] *= -1 if @color[:h]>=360 or @color[:h]<=0
  		@color_dir[:s] *= -1 if @color[:s]>=1 or @color[:s]<=0
  		@color[:h] += @color_dir[:h]
  		@color[:s] += @color_dir[:s]
  		@color[:h] = 0 if @color[:h]<0
  		@color[:s] = 0 if @color[:s]<0
	    @last_update = @update_limit
	end
  end
  def draw win
  	color = Gosu::Color.from_hsv @color[:h], @color[:s], 0.7
    win.draw_quad @pos[:x]-$size, @pos[:y]-$size, color,
                  @pos[:x]+$size, @pos[:y]-$size, color,
                  @pos[:x]+$size, @pos[:y]+$size, color,
                  @pos[:x]-$size, @pos[:y]+$size, color
  end
end
class GameWindow < Gosu::Window
  def initialize
    super $dimension, $dimension, false
    self.caption = "Color Dream"
    @quads = []
    $squares.times do |i|
    	$squares.times do |j|
    		@quads << Entity.new( i, j, self) 
    	end
    end
  end
  def update() @quads.each {|q| q.update } end
  def draw() @quads.each { |q| q.draw self } end
end
GameWindow.new.show                
                    //[C#]

// Connect to Exchange Server using ImapClient class
ImapClient imapClient = new ImapClient("ex07sp1", "Administrator", "Evaluation1");
imapClient.Connect(true);

// Select the Inbox folder
imapClient.SelectFolder(ImapFolderInfo.InBox);

// Get the list of messages
ImapMessageInfoCollection msgCollection = imapClient.ListMessages();
foreach (ImapMessageInfo msgInfo in msgCollection)
{
    Console.WriteLine(msgInfo.Subject);
}
// Disconnect from the server
imapClient.Disconnect();
 
//[VB.NET]

' Connect to Exchange Server using ImapClient class
Dim imapClient As ImapClient = New ImapClient("ex07sp1", "Administrator", "Evaluation1")
imapClient.Connect(True)

' Select the Inbox folder
imapClient.SelectFolder(ImapFolderInfo.InBox)

' Get the list of messages
Dim msgCollection As ImapMessageInfoCollection = imapClient.ListMessages()
For Each msgInfo As ImapMessageInfo In msgCollection
    Console.WriteLine(msgInfo.Subject)
Next msgInfo
' Disconnect from the server
imapClient.Disconnect()

//Programming Samples for SSL

//If the Exchange Server uses SSL, modify the above code as follows:

//[C#]

private void ConnectUsingSSL()
{
// Connect to Exchange Server using ImapClient class
ImapClient imapClient = new ImapClient("ex07sp1", 993, "Administrator", "Evaluation1", new RemoteCertificateValidationCallback(RemoteCertificateValidationHandler));
imapClient.EnableSsl = true;
imapClient.SecurityMode = ImapSslSecurityMode.Implicit;
imapClient.Connect(true);

lstLog.Items.Add("Connected to Exchange server");
// Select the Inbox folder
imapClient.SelectFolder(ImapFolderInfo.InBox);

// Get the list of messages
ImapMessageInfoCollection msgCollection = imapClient.ListMessages();
foreach (ImapMessageInfo msgInfo in msgCollection)
{
    Console.WriteLine(msgInfo.Subject);
}
// Disconnect from the server
imapClient.Disconnect();
}

// Certificate verification handler
private bool RemoteCertificateValidationHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
    return true; //ignore the checks and go ahead
}

//[VB.NET]

' Connect to Exchange Server using ImapClient class
Dim imapClient As ImapClient = New ImapClient("ex07sp1", 993, "Administrator", "Evaluation1", New RemoteCertificateValidationCallback(AddressOf RemoteCertificateValidationHandler))
imapClient.EnableSsl = True
imapClient.SecurityMode = ImapSslSecurityMode.Implicit
imapClient.Connect(True)

Console.WriteLine("Connected to Exchange server")
' Select the Inbox folder
imapClient.SelectFolder(ImapFolderInfo.InBox)

' Get the list of messages
Dim msgCollection As ImapMessageInfoCollection = imapClient.ListMessages()
For Each msgInfo As ImapMessageInfo In msgCollection
    Console.WriteLine(msgInfo.Subject)
Next msgInfo
' Disconnect from the server
imapClient.Disconnect()

' Certificate verification handler
Private Function RemoteCertificateValidationHandler(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean
    Return True 'ignore the checks and go ahead
End Function
 
//Programming Sample - Saving One Message Only

//After connecting to an Exchange server using IMAP and getting the IMapMessageInfoCollection, you can use the MessageInfo object's sequence number to save a specific message as follow:

//[C#]

// Get the list of messages
ImapMessageInfoCollection msgCollection = imapClient.ListMessages();
foreach (ImapMessageInfo msgInfo in msgCollection)
{
    //Fetch the message from inbox using its SequenceNumber from msgInfo
    MailMessage msg = imapClient.FetchMessage(msgInfo.SequenceNumber);

    //Save the message to disc now
    msg.Save(msgInfo.SequenceNumber + ".msg", MailMessageSaveType.OutlookMessageFormat);
}
                
                    #include "Main.h"
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>

#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600

#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL;
LPDIRECT3DINDEXBUFFER9 i_buffer = NULL;

void initD3D(HWND hWnd);
void render_frame(void);
void cleanD3D(void);
void init_graphics(void);
void init_light(void);  

struct CUSTOMVERTEX {FLOAT X, Y, Z; D3DVECTOR NORMAL;};
#define CUSTOMFVF (D3DFVF_XYZ | D3DFVF_NORMAL)

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    HWND hWnd;
    WNDCLASSEX wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.lpszClassName = L"WindowClass";

    RegisterClassEx(&wc);

    hWnd = CreateWindowEx(NULL, L"WindowClass", L"Our Direct3D Program",
                          WS_OVERLAPPEDWINDOW, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                          NULL, NULL, hInstance, NULL);

    ShowWindow(hWnd, nCmdShow);

    initD3D(hWnd);

    MSG msg;

    while(TRUE)
    {
        while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        if(msg.message == WM_QUIT)
            break;

        render_frame();
    }

    cleanD3D();

    return msg.wParam;
}


LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_DESTROY:
            {
                PostQuitMessage(0);
                return 0;
            } break;
    }

    return DefWindowProc (hWnd, message, wParam, lParam);
}


void initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);

    D3DPRESENT_PARAMETERS d3dpp;

    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = SCREEN_WIDTH;
    d3dpp.BackBufferHeight = SCREEN_HEIGHT;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);

    init_graphics();
    init_light();   

    d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE);
    d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); 
    d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50)); 
}

void render_frame(void)
{
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
    d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    d3ddev->BeginScene();
    d3ddev->SetFVF(CUSTOMFVF);

    D3DXMATRIX matView;
    D3DXMatrixLookAtLH(&matView,
    &D3DXVECTOR3 (0.0f, 8.0f, 25.0f),    
    &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),     
    &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));    
    d3ddev->SetTransform(D3DTS_VIEW, &matView);

   
    D3DXMATRIX matProjection;
    D3DXMatrixPerspectiveFovLH(&matProjection,
                               D3DXToRadian(45),
                               (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT,
                               1.0f,    
                               100.0f); 
    d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);

    
    static float index = 0.0f; index+=0.03f;
    D3DXMATRIX matRotateY;
    D3DXMatrixRotationY(&matRotateY, index);
    d3ddev->SetTransform(D3DTS_WORLD, &(matRotateY));

    d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
    d3ddev->SetIndices(i_buffer);

    d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12); 

    d3ddev->EndScene(); 

    d3ddev->Present(NULL, NULL, NULL, NULL);
}

void cleanD3D(void)
{
    v_buffer->Release();
    i_buffer->Release();
    d3ddev->Release();
    d3d->Release();
}

void init_graphics(void)
{
    CUSTOMVERTEX vertices[] =
    {
        { -3.0f, -3.0f, 3.0f, 0.0f, 0.0f, 1.0f, },    // side 1
        { 3.0f, -3.0f, 3.0f, 0.0f, 0.0f, 1.0f, },
        { -3.0f, 3.0f, 3.0f, 0.0f, 0.0f, 1.0f, },
        { 3.0f, 3.0f, 3.0f, 0.0f, 0.0f, 1.0f, },

        { -3.0f, -3.0f, -3.0f, 0.0f, 0.0f, -1.0f, },    // side 2
        { -3.0f, 3.0f, -3.0f, 0.0f, 0.0f, -1.0f, },
        { 3.0f, -3.0f, -3.0f, 0.0f, 0.0f, -1.0f, },
        { 3.0f, 3.0f, -3.0f, 0.0f, 0.0f, -1.0f, },

        { -3.0f, 3.0f, -3.0f, 0.0f, 1.0f, 0.0f, },    // side 3
        { -3.0f, 3.0f, 3.0f, 0.0f, 1.0f, 0.0f, },
        { 3.0f, 3.0f, -3.0f, 0.0f, 1.0f, 0.0f, },
        { 3.0f, 3.0f, 3.0f, 0.0f, 1.0f, 0.0f, },

        { -3.0f, -3.0f, -3.0f, 0.0f, -1.0f, 0.0f, },    // side 4
        { 3.0f, -3.0f, -3.0f, 0.0f, -1.0f, 0.0f, },
        { -3.0f, -3.0f, 3.0f, 0.0f, -1.0f, 0.0f, },
        { 3.0f, -3.0f, 3.0f, 0.0f, -1.0f, 0.0f, },

        { 3.0f, -3.0f, -3.0f, 1.0f, 0.0f, 0.0f, },    // side 5
        { 3.0f, 3.0f, -3.0f, 1.0f, 0.0f, 0.0f, },
        { 3.0f, -3.0f, 3.0f, 1.0f, 0.0f, 0.0f, },
        { 3.0f, 3.0f, 3.0f, 1.0f, 0.0f, 0.0f, },

        { -3.0f, -3.0f, -3.0f, -1.0f, 0.0f, 0.0f, },    // side 6
        { -3.0f, -3.0f, 3.0f, -1.0f, 0.0f, 0.0f, },
        { -3.0f, 3.0f, -3.0f, -1.0f, 0.0f, 0.0f, },
        { -3.0f, 3.0f, 3.0f, -1.0f, 0.0f, 0.0f, },
    };

    d3ddev->CreateVertexBuffer(24*sizeof(CUSTOMVERTEX),
                               0,
                               CUSTOMFVF,
                               D3DPOOL_MANAGED,
                               &v_buffer,
                               NULL);

    VOID* pVoid;    

    v_buffer->Lock(0, 0, (void**)&pVoid, 0);
    memcpy(pVoid, vertices, sizeof(vertices));
    v_buffer->Unlock();

    short indices[] =
    {
        0, 1, 2,    // side 1
        2, 1, 3,
        4, 5, 6,    // side 2
        6, 5, 7,
        8, 9, 10,    // side 3
        10, 9, 11,
        12, 13, 14,    // side 4
        14, 13, 15,
        16, 17, 18,    // side 5
        18, 17, 19,
        20, 21, 22,    // side 6
        22, 21, 23,
    };


    d3ddev->CreateIndexBuffer(36*sizeof(short),
                              0,
                              D3DFMT_INDEX16,
                              D3DPOOL_MANAGED,
                              &i_buffer,
                              NULL);

    i_buffer->Lock(0, 0, (void**)&pVoid, 0);
    memcpy(pVoid, indices, sizeof(indices));
    i_buffer->Unlock();
}


void init_light(void)
{
    D3DLIGHT9 light;    // create the light struct
    D3DMATERIAL9 material;    // create the material struct

    ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
    light.Type = D3DLIGHT_DIRECTIONAL;    // make the light type 'directional light'
    light.Diffuse = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);    // set the light's color
    light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f);

    d3ddev->SetLight(0, &light);    // send the light struct properties to light #0
    d3ddev->LightEnable(0, TRUE);    // turn on light #0

    ZeroMemory(&material, sizeof(D3DMATERIAL9));    // clear out the struct for use
    material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set diffuse color to white
    material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set ambient color to white

    d3ddev->SetMaterial(&material);    // set the globably-used material to &material
}
                
                    import PIL
from PIL import Image
import os
import sys

def readf():

    try:
        input_dir  = str(sys.argv[1].rstrip('/'))  #path to img source folder
        img_size   = str(sys.argv[2])  #The image size (128, 256,etc)
        output_dir  = str(sys.argv[3].rstrip('/')) #output directory
        print "starting...."
        print "Colecting data from %s " % input_dir
        tclass = [ d for d in os.listdir( input_dir ) ]
        counter = 0
        strdc = ''
        hasil = []
        for x in tclass:
           list_dir =  os.path.join(input_dir, x )
           list_tuj = os.path.join(output_dir+'/', x+'/')
           if not os.path.exists(list_tuj):
                os.makedirs(list_tuj)
           if os.path.exists(list_tuj):
               for d in os.listdir(list_dir):
                   try:
                       img = Image.open(os.path.join(input_dir+'/'+x,d))
                       img = img.resize((int(img_size),int(img_size)),Image.ANTIALIAS)
                       fname,extension = os.path.splitext(d)
                       newfile = fname+extension
                       if extension != ".jpg" :
                           newfile = fname + ".jpg"
                       img.save(os.path.join(output_dir+'/'+x,newfile),"JPEG",quality=90)
                       print "Resizing file : %s - %s " % (x,d)
                       
                   except Exception,e:
                        print "Error resize file : %s - %s " % (x,d)
                        sys.exit(1)
                  
               counter +=1
        
    except Exception,e:
        print "Error, check Input directory etc : ", e
        sys.exit(1)
     
readf()
                
                    #!/usr/bin/env ruby
require 'gosu' # gem install gosu

$width, $height = 200, 200
$number_of_v_lines,$number_of_h_lines = 10, 10
$chars = ('a'..'z').to_a

class Entity
  def initialize(x,y,vel, win)
    @pos, @vel = {x:x, y:y}, vel
    @font = Gosu::Font.new(win, Gosu::default_font_name, rand(20)+10)
    @char = rand($chars.length)
    @update_limit = rand(50)+10
    @last_update = @update_limit
  end
  def update
  	@last_update -= 1
  	if @last_update==0
	  	@char = (@char==$chars.length-1)? 0 : @char+1
	    @last_update = @update_limit
	end
    @pos[:y] = @pos[:y] >= $height+10 ? -10 : @pos[:y] + @vel 
  end
  def draw
    @font.draw($chars[@char], @pos[:x], @pos[:y], 0, 1.0, 1.0, Gosu::Color::GREEN)
  end
end
class GameWindow < Gosu::Window
  def initialize
    super $width, $height, false
    self.caption = "Matrix"
    @quads = []
    $number_of_v_lines.times do |i|
    	vel = rand(3)+1
    	$number_of_h_lines.times do |j|
    		@quads << Entity.new( $width/$number_of_v_lines*i, $height/$number_of_h_lines*j, vel, self) 
    	end
    end
  end
  def update() @quads.each {|q| q.update } end
  def draw() @quads.each { |q| q.draw } end
end
GameWindow.new.show