Codes for the ANIMATION/GAME using processing

Asked By 0 points N/A Posted on -
qa-featured

I had this project in computer science. We will be making an animation, or a game using processing. I'm planning to make a snake or puzzle game. Can you help me finding out the  the codes of the game using processing 1.5.1? or you can suggest the game and provide the codes.

Thank you so much!

SHARE
Best Answer by Abbyarc
Best Answer
Best Answer
Answered By 0 points N/A #99405

Codes for the ANIMATION/GAME using processing

qa-featured

 

Good Day Hpaadict!

Since your inquiry is about processing and finding the right code. You might consider these codes you can try to play it on processing. And also you can make some adjustments to this code to make your game. Don’t forget that the properties of an object is called variables and it is important for every codes that you will create, the key programming fundamentals is the marriage of object-oriented programming with data and functionality. On implementing the pseudo-codes you will need global variables on top the program you are making. Also consider the four main elements which are the name, data, constructor, and methods.





PFont fontA;

  int sphereDiameter = 10;
  boolean shoot = false;
  
  int randx()
  {
    return int(random(600));
  }
  
  int[] sphereXCoords = { randx(), randx(), randx(), randx(), randx() };
  int[] sphereYCoords = { 0, 0, 0, 0, 0 };
  
  void setup()
  {
    size(600,620);
  }
  
  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();  
  }
  
  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();
      }
    }
  }
 

 

Answered By 0 points N/A #196212

Codes for the ANIMATION/GAME using processing

qa-featured

Good day,

To animate an element moving 400 pixels on the right with javascript, the basic thing to do is to move it 10 pixels at a time on a regular interval.An HTML5 game based on this logic would normally run at ~60fps[2], but if the animations were too complex or running on a low-spec. device (a mobile phone for instance) and processing a frame were taking more than 16ms, then the game would run at a lower framerate: when processing 1 frame takes 33ms, the game runs at 30fps and game elements move twice as slowly as they should. Animations would still look smooth enough, but the game experience would be altered.

Regards,

Jacksonn Maria

Related Questions