Only got my Arduboy on friday and i am very new to coding .
I have created a little bird and i have read the help and info on making a guy walk so now he is animated, before this i had him moving across the screen up and down etc,
1 i cant seem to get him to be animated and move around the screen ?
2 how can i change the action so if i wanted him to be still untill i press the move arrow and then walk ( and eventually
jump (fly) when i press A) ?
would it be helpful if i put the code i have so far on here?
sooo I. have had a go at using this code.[quote=“Celinebins, post:9, topic:3628”]
This MAY also help a little, its @JO3RI’s article in the Vol 4 Arduboy Magazine
[/quote]
to move my animaltion and I have got stuck , it says I cannot use STAND_STILL_R as a constant.
I know i have done somthing wrong above, any ideas what it could be?
@Zanners59, I (@MLXXXp) have edited this post to properly format the code by enclosing it in ```cpp on a line at the start and ``` on a line at the end.
#include"BITMAP.H"
#include <Arduboy2.h>
#include <Arduboy.h>
//Variables declared here
int spritestate = 0;
int playerX = 5;
int playerY = 10;
int justpressed = 0;
int playeriswalking = false;
int playerisjumping = false;
int playerisstill= false;
int playerisflying = false;
int STAND_STILL ;
int WALK_RIGHT ;
int FLY_RIGHT ;
int JUMP ;
Arduboy2 arduboy;
Sprites sprites;
byte frame = 0;
void setup() {
arduboy.begin();
//Set-up here
arduboy.clear();
arduboy.setFrameRate(30);
}
void loop() {
if (!(arduboy.nextFrame())) return;
arduboy.clear();
sprites.drawSelfMasked(playerX, playerY, Bertie_idle_R , frame);
if (arduboy.everyXFrames(3)) frame++;
spritestate = STAND_STILL;
if (arduboy.justPressed(RIGHT_BUTTON)){
playeriswalking = true;
playerX --;
if(arduboy.justPressed(B_BUTTON)and (RIGHT_BUTTON)){
playerY--;
spritestate = FLY_RIGHT;
playerisflying = true;
}
else spritestate = WALK_RIGHT;
playeriswalking= true;
}
//else if JUMP AND WALK LEFT
if (arduboy.justPressed(B_BUTTON)){
playerY--;
spritestate = JUMP;
playerisflying = true;
}
switch (spritestate){
case STAND_STILL :
sprite.drawPlusMask(playerX, PlayerY, Bertie_idle_R,frame )
playerisstanding = true;
break;
case WALK_RIGHT:
sprite.drawPlusMask(playerX, PlayerY, Bertie_walk_animated_R, frame)
playeriswalking = true;
break;
case FLY_RIGHT:
sprite.drawPlusMask(PlayerX, PlayerY, Bertie_fly_animate_R,frame)
playerisflying = true;
//case walk left&jumpleft
}
}
arduboy.display();
}
please be aware that a am really new at this and i think there are probably other things that are wrong as well !!
Also Thanks to this amazing community who help out us newbies, you are amazing.
Using enum is an easy way of assigning incrementing values to each constant declared in the enumeration. STAND_STILL will be given a value of 0, WALK_RIGHT will equal 1, etc.
If you’re only going to assign true or false to a variable, you should make it a boolean or bool. (boolean and bool are equivalent. boolean is the Arduino type name, bool is standard C++. Use what you prefer.)