Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Zoho Docs
Google Docs
Each Attachment size should not exceed 1MB.
Max no of attachments : 0
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
New to this Portal?
Click on Join Now to Sign Up
Join Now
Help
Feedback
Sign In
Processing Forum
Recent Topics
All Forums
Search All
Tags
Author
Advanced Search
Search
New Topic
Screen name:
alexc1337
alexc1337's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Adding an on-screen counter? As well as a few others questions.
[1Reply]
07-Jun-2012 06:21 AM
Forum:
Programming Questions
Hey guys... below is my code. I'm just wondering how to make an on screen counter? As well as a 'Game Over' screen with a transparent PNG image coming up saying 'GAME OVER'
PImage b;
PImage cc;
int cakeDiameter = 35;
boolean shoot = false;
int[] cakeXCoords = {
randx(), randx(), randx(), randx(), randx(),
randx(), randx(), randx(), randx(), randx()
};
int[] cakeYCoords = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
void setup()
{
size(1024, 768);
b = loadImage("Background.jpg");
cc= loadImage("Cupcake.png");
}
void draw()
{
background(b);
fill(color(0, 255, 0));
stroke(color(0, 255, 0));
triangle(mouseX-8, 730, mouseX+8, 730, mouseX, 715);
text("Move with the mouse", 25, 100);
text("Click to shoot", 25, 150);
cakeDropper();
}
void mousePressed()
{
shoot = true;
}
void cakeDropper()
{
stroke(255);
fill(255);
imageMode(CENTER);
if (shoot==true)
{
fill( random(255), random(255), random(255), random(255));
cakeKiller(mouseX);
shoot = false;
}
for (int i=0; i<10; i++)
{
image(cc, cakeXCoords[i], cakeYCoords[i]+=1);
}
}
void cakeKiller(int shotX)
{
boolean hit = false;
for (int i = 0; i < 10; i++)
{
if ((shotX >= (cakeXCoords[i]-cakeDiameter/2)) &&
(shotX <= (cakeXCoords[i]+cakeDiameter/2)))
{
hit = true;
line(mouseX, 700, mouseX, cakeYCoords[i]);
ellipse(cakeXCoords[i], cakeYCoords[i],
cakeDiameter+25, cakeDiameter+25);
cakeXCoords[i] = randx();
cakeYCoords[i] = 0;
}
}
if (hit == false)
{
line(mouseX, 700, mouseX, 0);
}
}
int randx()
{
return int(random(1000));
}
«Prev
Next »
Moderate user : alexc1337
Forum