Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.atm959.sourceCode;
- import java.awt.Graphics;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import java.util.Random;
- import javax.imageio.ImageIO;
- public class Clouds {
- public static Random random = new Random();
- public static int[] cloudXPositions = {random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32), random.nextInt(Component.PIXEL.width - 32)};
- public static int[] cloudYPositions = {random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16), random.nextInt(Component.PIXEL.height - 16)};
- public static double cloudOffset;
- BufferedImage cloud;
- public static int i;
- public Clouds() throws IOException{
- System.out.println("Loaded Clouds.java");
- cloud = ImageIO.read(new File("res/images/cloud.png"));
- }
- public void tick(){
- cloudOffset += 0.5;
- if(cloudOffset > Component.PIXEL.width){
- for(i = 0; i <= 9; i++){
- cloudXPositions[i] = random.nextInt(random.nextInt(Component.PIXEL.width - 32));
- cloudYPositions[i] = random.nextInt(random.nextInt(Component.PIXEL.height - 16));
- }
- cloudOffset = (-Component.PIXEL.width);
- }
- }
- public void render(Graphics g){
- for(i = 0; i <= 9; i++){
- g.drawImage(cloud, cloudXPositions[i] + (int)cloudOffset, cloudYPositions[i], null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment