|
|
|||||||
| Computers & Information Technologies « Everything related to computers and internet. » |
![]() |
|
|
Share | Thread Tools | Search this Thread |
|
|
#11 |
|
Last Online: 12-20-2021
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,121
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
|
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.
|
|
|
|
| The Following User Says Thank You to Tawa For This Useful Post: | 7alewi (12-29-2009) |
|
|
#12 |
|
Registered Member
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
|
or just use flash for gfx based ria :/
__________________
I pwn n00bs |
|
|
|
![]() |
|
| Tags |
| language, processing, programming |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|