Alright, I'm attempting to implement a simple game in Processing. However, I'm hitting some road bumps...
First off, since there doesn't seem to be a built in way to scale screen size, is there any way to, let's say, render the window at 1x, but render the content at 2x? For example, you have a window that's 100x100, and content that fills 50x50. Is there any way to scale the content to be 100x100 in code?
Secondly, I don't quite understand updatePixels...
I had a drawing function...
-
void draw(){PImage player;player = loadImage("pwalk2.png");image(player, playerx, playery);if(keyPressed) {if (key == ' ') {if(x > 0) {playerx = playerx + 1;}else {playerx = playerx - 1;}}}}
...but the way that it's drawn, it will show all previous locations of the player sprite on top of showing the current location, leaving an endless trail of player sprites.
So I added the updatePixels function...
-
void draw(){PImage player;player = loadImage("pwalk2.png");image(player, playerx, playery);updatePixels();if(keyPressed) {if (key == ' ') {if(x > 0) {playerx = playerx + 1;}else {playerx = playerx - 1;}}}}
...but I got a Null Pointer Exception and the player wasn't being drawn at all. So I changed the updatePixels call to...
- updatePixels(playerx, playery, 9, 8);
...but I'm still getting a Null Pointer Exception. How do I get it to show only the current location of the sprite, all the while not giving me a Null Pointer Exception?
1