Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
dashofsarcasm
dashofsarcasm's Profile
3
Posts
2
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
Space invaders help
[1 Reply]
02-Feb-2013 02:44 PM
Forum:
Programming Questions
I cant get the laser to fire correctly. i want it to start rising as a bullet does when the mouse is pressed. Disregard the commented code on lines 8 and 18.
int x=mouseX;
int y=560;
int z=540;
void setup(){
size(600,600);
background(100,0,200);
// img = loadImage("spaceship.png");
}
void draw(){
spaceship();
laser();
}
void spaceship(){
fill(255,0,0);
background(100,0,200);
//img = loadImage("spaceship.png");
triangle(mouseX-18,580,mouseX+18, 580, mouseX,560);
laser();
}
void laser(){
strokeWeight(5);
stroke(255,0,0);
if(mousePressed == true){
line(mouseX, z, mouseX , y);
}
y--;
z--;
}
need help with game!
[5 Replies]
24-Jan-2013 11:32 PM
Forum:
Programming Questions
//Pimp Man
boolean displayStartScreen;
int xmove = 0; int ymove = 0;
int xpos = 150; int ypos = 150;
int row = 0; int col = 0;
int x = 175; int y = 100;
void setup() {
size(800, 800); //size of game
textAlign(CENTER, CENTER); //alignment of timer
displayStartScreen = true;
}
void draw() {
if ( displayStartScreen ) {
drawStartScreen(); //call Start Screen
} else {
background(0); // Black background
fill(255);
text( "" + millis() / 1000, 35, 20 );
fill(255,140,5);
rect(450,650,50,50);
line(200, 100, 200, 400);
line(200, 400, 475, 400);
line(475, 400, 475, 650);
stroke(255);
player(x,y,xpos,ypos);
}
}
void player(int x,int y, int xpos, int ypos) {
fill(0,255,0);
rect(x,y,50,50);
}
void drawStartScreen() { //Start Screen
background(0); //Black Background
textSize(20);
text("*Hurry, timer has already started!*", width/2, 500);
textSize(30);
text("Press Enter/Return to Start", width/2, height/2); //How to Start
textSize(70);
text("PIMP MAN", 400, 200); //Game Title
}
void check(){
if (row > 7 || col > 7 || row < 0 || col < 0 ){
background(255);
}
}
void keyPressed() {
if ( displayStartScreen ) {
if (key == ENTER || key == RETURN) { //Pushed to Start
displayStartScreen = false;
if(key == UP) {
ymove = ymove-100;
col = col-1;
check();
}
if(key == LEFT){
xmove = xmove-100;
row = row-1;
check();
}
if(key == RIGHT){
xmove = xmove+100;
row = row+1;
check();
}
if(key == DOWN){
ymove = ymove+100;
col = col+1;
check();
}
}
}
}
void animate( ){
player(x, y, xpos, ypos);
if(xmove > 0){
xpos = xpos + 1;
xmove = xmove - 1;
}
if(ymove > 0){
ypos = ypos + 1;
ymove = ymove -1;
}
}
i cant get the green square to move need help
Cant get my if statement to wrok
[3 Replies]
24-Jan-2013 11:28 AM
Forum:
Programming Questions
Im trying to make a game and im pretty sure my if statement is terribly wrong
i wantit to draw the start screen when enter or return are pressed
//Pimp_Man
int time; //Timer for elapsed time
int m = millis(); //Shorten time used to type "millis()"
void setup() {
noLoop();
size(800,800); //size of game
textSize(20); //size of timer text
textAlign(100,100); //alignment of timer
}
void draw() {
begin(); //call Start Screen
background(255); //White Background
time=m/1000; //Timer itself
}
void begin() { //Start Screen
background(0); //Black Background
text("PIMP MAN",400,200); //Game Title
text("Press Return to Start",width/2,height/2); //How to Start
if(keyPressed == ENTER || keyPressed == RETURN) { //Pushed to Start
loop();
}
}
«Prev
Next »
Moderate user : dashofsarcasm
Forum