Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Wie ändere ich genau in diesem Beispiel die Gametime() und abhängig von der Rendertime()?
- final int X = 30;
- final int S = 10;
- float bullet_x;
- PImage alien_pic;
- PImage shooter_pic;
- class Alien{
- float x,y;
- float vx,vy;
- int i;
- int down;
- Alien(float x_Pos, float y_Pos){
- x = x_Pos;
- y = y_Pos;
- vx = 30;
- vy = 30;
- down = 0;
- }
- void move(){
- if(down==0){x = x + 30;}
- if (x == width){
- x = width;
- for (int i=0; i<=1;i++){y = y + vy; down=1;}
- }
- if (down==1){
- vy=0;
- x = x - 30;
- }
- if (down==1){
- if (x==0){
- x = 0; vy=X;
- for (int i=0; i<=1;i++){y = y + vy; down=0;}
- }
- }
- }
- void display(){
- image(alien_pic,x,y);
- move();
- }
- }
- class Shooter{
- float x,y;
- Shooter(float x_Pos, float y_Pos){
- x = x_Pos;
- y = y_Pos;
- }
- void display(){
- image(shooter_pic,x,y);
- }
- }
- //Bullet Class ist noch unter kompletter Bearbeitung!!
- class Bullet{
- float x,y;
- float w,h;
- float vy;
- Bullet(){
- x = 8*X;
- y = 2*X;
- w = 5;
- h = 15;
- vy = 0;
- }
- void move(){
- y = y - vy;
- }
- void display(){
- rect(x,y,w,h);
- println(x);
- }
- }
- Alien alien1 = new Alien(X,X);
- Alien alien2 = new Alien(3*X,X);
- Alien alien3 = new Alien(5*X,X);
- Bullet bullet = new Bullet();
- Shooter shooter = new Shooter(8*X,18*X);
- void setup(){
- size(17*X,19*X);
- background(0);
- frameRate(5);
- alien_pic = loadImage("alien.jpg");
- shooter_pic = loadImage("shooter.jpg");
- }
- void draw(){
- background(0);
- alien1.display();
- alien2.display();
- alien3.display();
- shooter.display();
- bullet.display();
- }
- void keyPressed(){ //LEFT und RIGHT funktioniert nicht, keine Ahnung warum
- //if (key == CODED){
- if (key == 'a'){
- shooter.x = shooter.x - 30;
- bullet_x = shooter.x;
- }
- if (key == 'd'){
- shooter.x = shooter.x + 30;
- bullet_x = shooter.x;
- }
- /*if (key == 'Space'){
- bullet.vy = bullet.vy + S;
- }*/
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement