Background image with refreshScreen command
in
Programming Questions
•
9 months ago
Hi there. I'm really new to coding and would appreciate any help that I can get. I came across this awesome
webpage while trying to research into making games with Processing. It mods a classic Atari game and I'm trying to do the same since they supplied the basic coding to do so.
All I want to know is how do I have a background image within this code? I know how to load an image in Processing but the issue is that there's a refreshScreen() command in the void setup and void draw which gets rid of the the background image. And if I get rid of the refreshScreen() command, then it doesn't run the game, it just loads the image and that's it.
The code is below if you want to take a look:
PImage bg;
Rectangle gameFrame;
Brick[] bricks;
Paddle paddle;
Ball[] balls;
//
//
int frameNum = 0;
//
// SCREEN PROPERTIES --
int screenWidth = 500;
int screenHeight = 500;
color backgroundColor = #303030;
boolean backgroundRefreshes = false;
//
// GAME FRAME PROPERTIES --
int gameFrameWidth = 500;
int gameFrameHeight = 500;
color gameFrameStroke = #FFFFFF;
boolean gameFrameHasStroke = false;
color gameFrameFill = #000000;
int opacityOfRefresh = 255;
boolean gameFrameRefreshes = true;
//
//
int recX = (screenWidth-gameFrameWidth)/2;
int recY = (screenHeight-gameFrameHeight)/2;
//
// SETUP FUNCTION --
void setup() {
size(screenWidth,screenHeight,P3D);
frameRate(60);
//
// create objects
gameFrame = new Rectangle(gameFrameWidth, gameFrameHeight, gameFrameHasStroke, gameFrameStroke, true, gameFrameFill);
gameFrame.opacity = opacityOfRefresh;
createBricks();
createBalls();
paddle = new Paddle();
//
refreshScreen();
bg = loadImage("photo_edit1.jpg");
}
1