Vcoderz Community
We create websites that have it all, beauty & brains
Lebanon Web Design & Development - Coddict
 

Go Back   Vcoderz Community > Computer Zone > Computers & Information Technologies

Notices

Computers & Information Technologies Everything related to computers and internet.

Reply
 
Share Thread Tools Search this Thread
Old 12-29-2009   #11
Tawa
 
Tawa's Avatar
 
Last Online: 08-02-2018
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,120
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
Default

Nice one, just a small tip for the people who are interested in here.

You can run Processing in Eclipse [The Java Development Environment], you just need to import the file "core.jar" into the Project folder, and you have to write your code into a class, And you should turn the methods into public ones.

So the code given by RayanHalawi becomes like this:

Code:
import processing.core.*;

public class MyProcessingSketch extends PApplet {
    PFont fontA;
    int sphereDiameter = 20;
    boolean shoot = false;
      
    int randx(){
        return (int)random(600);
    }

    int[] sphereXCoords = { randx(), randx(), randx(), randx(), randx() };
    int[] sphereYCoords = { 0, 0, 0, 0, 0 };
      
    public void setup(){
        size(600,620);
    }
      
    public void draw()
    {
        background(0);
        fill(color(0,255,0));
        stroke(color(0,255,0));
        triangle(mouseX-8, 580, mouseX+8, 580, mouseX, 565);
        fill(color(255,0,0));
        stroke(color(255,0,0));
      
        if(shoot==true){
            sphereKiller(mouseX);
            shoot = false;
        }
      
        sphereDropper();
        gameEnder();  
    }
      
    public void mousePressed(){
        shoot = true;
    }
    
    void sphereDropper(){  
        stroke(255);
        fill(255);
        for (int i=0; i<5; i++){
            ellipse(sphereXCoords[i], sphereYCoords[i]++, sphereDiameter, sphereDiameter);
        }
    }
      
    void sphereKiller(int shotX)
    {
        boolean hit = false;
        for (int i = 0; i < 5; i++){
            if((shotX >= (sphereXCoords[i]-sphereDiameter/2)) && (shotX <= (sphereXCoords[i]+sphereDiameter/2))){
                hit = true;
                line(mouseX, 565, mouseX, sphereYCoords[i]);
                ellipse(sphereXCoords[i], sphereYCoords[i], sphereDiameter+25, sphereDiameter+25);
                sphereXCoords[i] = randx();
                sphereYCoords[i] = 0;
            }    
        }
      
        if(hit == false){
            line(mouseX, 565, mouseX, 0);
        }  
      
      }
      
      void gameEnder(){
          for (int i=0; i< 5; i++){
              if(sphereYCoords[i]==600){
                  fill(color(255,0,0));
                  noLoop();
              }
          }
      }
}


__________________
What we do in life, echoes in eternity.
Tawa is offline   Reply With Quote
The Following User Says Thank You to Tawa For This Useful Post:
7alewi (12-29-2009)
Old 01-03-2010   #12
ZeRaW
Registered Member
 
ZeRaW's Avatar
 
Last Online: 04-15-2018
Join Date: Feb 2006
Posts: 624
Thanks: 2
Thanked 299 Times in 276 Posts
Groans: 0
Groaned at 1 Time in 1 Post
Default

or just use flash for gfx based ria :/
__________________
I pwn n00bs
ZeRaW is offline   Reply With Quote
Reply

  Vcoderz Community > Computer Zone > Computers & Information Technologies

Tags
language, processing, programming



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:56 AM.


Lebanon web design and development
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Share