Skip to content

Instantly share code, notes, and snippets.

@sgodycki
Created September 17, 2021 15:57
Show Gist options
  • Save sgodycki/e2a84c39f6b22dd3191d50cc7c543b26 to your computer and use it in GitHub Desktop.
Save sgodycki/e2a84c39f6b22dd3191d50cc7c543b26 to your computer and use it in GitHub Desktop.
Homework map error message
def setup():
size(800,375)
global mountainsImage
global hillsImage
global foregroundImage
global princesspeachImage
global moonImage
mountainsImage = loadImage("week03-mountains.png")
hillsImage = loadImage("week03-hills.png")
foregroundImage = loadImage("week03-foreground.png")
princesspeachImage =loadImage("princesspeach.png")
moonImage = loadImage("week03-moon.png")
def draw():
rg = map(mouseX, 0,width, 155,10)
b = map(mouseX, 0,width, 255,50)
background(rg,rg,b)
mtnX=map(mouseX,0,200,0,-20)
image(mountainsImage, mtnX, 50)
hillsX = map(mouseX, 0, width, -20,-200)
image(hillsImage, hillsX, 250)
fgX = map(mouseX, 0, width, 0, -2000)
image(foregroundImage, fgX, 225)
mode=Python
mode.id=jycessing.mode.PythonMode
@sgodycki
Copy link
Author

NullPointerException can be a tough one to debug because I would say that is one of the least informative error messages that you can get.

In this case, my guess is that one or more of the image files that you're referencing by name on lines 8-12 is missing from your sketch folder. Can you confirm that all 5 image files are present in your sketch folder and the the filenames precisely match the filenames that you are using in your code? (If you're unsure how to confirm this, from within Processing you can go to the menu and click Sketch > Show Sketch folder, or type ⌘K, then look for the files in the sketch folder, and also look inside the folder named data.)

If any of the files are missing or the names are different, either add them, rename them, or correct the filename in your code.

If you're sure all the files are in there with the same filenames that you're using, please create a new Gist and tag me in that, as I'd like to have a look at the code as you've updated it.

Let me know if that works!

Yes thank u that ended up working !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment