Question: Hello, I am having an issue with my processing code. shuffle ( string [ ] ) does not exist. Please help, here is the code:
Hello, I am having an issue with my processing code. shufflestring does not exist. Please help, here is the code:
import processing.core.;
Import SoundFile class
import processing.sound.;
import core processing library
PImage sprite, beach, landscape, school;
Declare image variables
PApplet p;
Declare PApplet variable
String backgrounds
"beach.png
"landscape.png
"schoolipng.png
;
Array for background images
String sounds
"beachsound.mp
"landscapesound.mp
"schoolsound.mp
;
Track current scene index
int currentScene ;
Initial sprite position
int spriteX ;
Flag to control walking animation
boolean walking false;
Direction of sprite movement
boolean walkingRight true;
void setup
p this; Assign PApplet instance
size; Set window size
Load images and sounds
sprite loadImagepngeggpng;
beach loadImagebeachpng;
landscape loadImagelandscapepng;
school loadImageschoolipngpng;
Randomly shuffle background and sound order
shufflebackgrounds;
void draw
backgroundloadImagebackgroundscurrentScene; Set background image
Handle sprite movement
if walking
if walkingRight
spriteX ; Move sprite right
if spriteX sprite.width width
walking false; Stop walking at screen edge
playNextSound; Play next scene's sound
currentScene currentScene backgrounds.length; Wrap around to next scene
else
spriteX ; Move sprite left
if spriteX
walking false; Stop walking at screen edge
playNextSound; Play next scene's sound
currentScene currentScene backgrounds.length backgrounds.length; Wrap around to previous scene
Draw sprite based on direction
if walkingRight
imagesprite spriteX, height sprite.height;
else
imagesprite spriteX sprite.width, height sprite.height, sprite.width, sprite.height; Flip image horizontally
Stop the program after completing all scenes
if currentScene && walking
noLoop;
void mousePressed
walking true; Start walking animation on mouse press
if spriteX width
walkingRight false; Start walking left if clicked on the right half
void playNextSound
Play the sound file corresponding to the current scene
SoundFile sound new SoundFilep soundscurrentScene;
sound.play;
Please note that this is processing code not javascript
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
