PROCESSING- Layer festlegen und undurchlässige objekte erstellen?

hallo, wir haben in der schule seit kurzen ein paar pogrammier grundlagen mit processing.

das ziel ist es ein kleines spiel selbst zu programmieren.

ich habe mit einem spiel angefangen in dem man einen kleinen character hat (eine png datei) den man nach rechts und links steuern kann und der springen kann.

außerdem habe ich ein paar röhren eingebaut durch die der character hindurchlaufen soll.

hier kommen wir zu meiner ersten Frage: ist es möglich das ich verschiedene laye festlege, also das die röhren über dem character liegen, diesen also verdecken?

und meine zweite frage ist: ich habe ein paar schwebende plattformen erstellt auf die der character hinaufspringen können soll. allerdings fällt dieser momentan noch einfach hindurch. wie bekomme ich diese platformen solide? d.h. das wenn der character darauf landet, soll er darauf stehen bleiben und nicht hindurchfallen.

anbei noch der code, allerdings ziemlich wirr.

gif&gif2 = chaacter

danke schonmal.

PImage[] gif;
PImage [] gif2;
int nof;
int f;    // für die Laufanimation
int k;
PImage platform;
PImage hintergrund;
PImage Rohr;
PImage Rohr2;
int x = 0;
float y = 0;
boolean mover;
boolean movel;
boolean springen;
boolean rohr = false;


float jump;


boolean rechts;








void setup() {
  frameRate(130);
  size(1920, 1080);


  Rohr = loadImage("R.png");
  Rohr2 = loadImage("R2.png");
  platform = loadImage("platform.png");


  nof = 5;  
  gif = new PImage[nof];  
  int i = 0;  
  while (i < nof) { 


    gif[i] = loadImage("pixil-frame-"+i+".png");


    i=i+1;
  }   // laufanimation rechts




  gif2 = new PImage[nof];  
  int g = 0;  
  while (g    < nof) { 


    gif2[g] = loadImage("pixi-frame-"+g+".png");
    g=g+1;
  }   // laufanimation links








  hintergrund = loadImage("hintergrund.png");


  movel = false;
  mover = false;
  rechts = true;


  x = 50;
  y = 880;
  jump = 0;
}


void draw() {
  background(hintergrund);


  rohr = x > 0 && x < 10 && y > 370 && y < 490;


  println (mouseX+","+mouseY);






  image(Rohr, -20, 350, 100, 150);


  image(Rohr2, 1840, 60, 100, 150);
  image (platform, 0, 490);
  image (platform, 1660, 200);


  if (rechts) {


    image(gif[f], x, y, 160, 120);  //anfang laufen


    if (frameCount % 5 == 0)   f = f + 1;
    if (f == nof) f = 0;
  } else {
    image (gif2[k], x, y, 160, 120);


    if (frameCount % 5 == 0)   k = k + 1;
    if (k == nof) k = 0;
  }


  y = min(y+jump, 880);


  jump = jump + .28;








  if (x > 1300) {
    x = -150;
  }


  if (rohr) {
    x = 1300;
  }


  if (mover) {
    x = x+3;
  }
  if (movel) {
    x = x-3;
  }




  if (springen) {
    y = y - 5;
  }
}




void keyPressed() {


  if (key == ' ') {
    jump= -8;
  }


  if (keyCode == RIGHT) {




    mover = true;
    rechts = true;
  }




  if (keyCode == LEFT) {
    movel = true;
    rechts = false;
  }
}


void keyReleased() {
  if (keyCode == RIGHT) {
    mover = false;
  }
  if (keyCode == LEFT) {
    movel = false;
  }




  println (mouseX+","+mouseY);
}


Computer, programmieren, Java, Informatik, Processing, Spiele und Gaming

Meistgelesene Beiträge zum Thema Spiele und Gaming