chrisz
(Christian)
January 12, 2018, 4:30pm
#1
hi guys,
I’m trying to making my own game.
i’ve to do something like this
#include <Arduboy2.h>
Arduboy2 arduboy;
int selectedmenu = 0;
int menustate = 0;
bool inmenu = true;
int lbuffer = 0;
int rbuffer = 0;
void setup() {
arduboy.begin();
arduboy.setFrameRate(60);
arduboy.bootLogoExtra();
}
void loop() {
arduboy.clear();
//**********************************//
arduboy.drawCircle(64, 32, 30);
if(menustate == 0){
arduboy.setCursor(51 ,55);
arduboy.print("start");
arduboy.setCursor(53, 0);
arduboy.print("info");
}
if(menustate == 1){
arduboy.setCursor(51, 0);
arduboy.print("start");
arduboy.setCursor(53, 55);
arduboy.print("info");
}
if(arduboy.pressed(RIGHT_BUTTON) && rbuffer == 0 && menustate == 1) { menustate = 0; rbuffer = 1;}
if(arduboy.pressed(LEFT_BUTTON) && lbuffer == 0 && menustate == 0){ menustate = 0; lbuffer = 1;}
if(!arduboy.notPressed(LEFT_BUTTON)) {
lbuffer = 0;
}
if(arduboy.notPressed(RIGHT_BUTTON)) {
rbuffer = 0;
}
//*********************************//
arduboy.setCursor(0,0);
arduboy.print(arduboy.cpuLoad());
arduboy.display();
}
but it doesn’t work,
can someone help me to find the error please?
Pharap
(Pharap)
January 12, 2018, 4:57pm
#2
Are those underscores present in your original code or are you just using those to mark the start and end of your code?
If you want to put your code in a code block on the forums here then start and end it with ```(three ‘graves ’).
When you say the code “doesn’t work” do you mean it doesn’t compile or it doesn’t do what you want it too?
If it’s not compiling, what is the compilation error?
If it doesn’t do what you want it to:
what is it doing?
what do you want it to do?
how is what it is doing different from what you want it to do?
1 Like
chrisz
(Christian)
January 12, 2018, 5:14pm
#3
Pharap:
Are those underscores present in your original code or are you just using those to mark the start and end of your code?
If you want to put your code in a code block on the forums here then start and end it with ```(three ‘graves’).
edited, thank you.
Pharap:
When you say the code “doesn’t work” do you mean it doesn’t compile or it doesn’t do what you want it too?
If it’s not compiling, what is the compilation error?
I mean that it doesn’t do what I want it do
invert the position of the two text ( info , start)
Pharap:
what is it doing?
nothing only this part of code:
chrisz:
arduboy.drawCircle(64, 32, 30);
if(menustate == 0){
arduboy.setCursor(51 ,55);
arduboy.print(“start”);
arduboy.setCursor(53, 0);
arduboy.print(“info”);
Pharap
(Pharap)
January 12, 2018, 5:20pm
#4
I think your main problem is with:
if(arduboy.pressed(RIGHT_BUTTON) && rbuffer == 0 && menustate == 1) { menustate = 0; rbuffer = 1;}
if(arduboy.pressed(LEFT_BUTTON) && lbuffer == 0 && menustate == 0){ menustate = 0; lbuffer = 1;}
It looks like the second one should be menustate = 1;
instead of menustate = 0;
I also notice that there’s a small discrepency here:
if(!arduboy.notPressed(LEFT_BUTTON)) {
lbuffer = 0;
}
if(arduboy.notPressed(RIGHT_BUTTON)) {
rbuffer = 0;
}
The first one has a !
which inverts the result, meaning !arduboy.notPressed(LEFT_BUTTON)
is the same as arduboy.pressed(LEFT_BUTTON)
.
chrisz
(Christian)
January 12, 2018, 5:30pm
#5
thank you for the reply, now it works!
1 Like
I’ve been using 3x Tilde
~~~
Code
~~~
In my defence graves are hidden under a long key press on the IOS keyboard. Making it 2 presses and a swipe for each one.
1 Like
Pharap
(Pharap)
January 12, 2018, 6:55pm
#7
Keyboard_Camper:
I’ve been using 3x Tilde
At least you know now, that’s the important thing.
The list of reasons I don’t like smartphones never stops growing it seems. :P
On a standard British keyboard layout the grave is to the left of the 1 key, above the tab.
It’s also a ¬ (a logical negation in certain mathematical logic systems) if you hold shift or a ¦ if you use alt-gr (a broken vertical bar , which is pretty useless. I’d rather it were an obelus .).
1 Like
filmote
(Simon)
January 12, 2018, 10:03pm
#8
I You do know that you can simply highlight the text and press either the quote or code button?
1 Like
Pharap
(Pharap)
January 12, 2018, 10:44pm
#9
Good tip, though it seems someone hasn’t had their breakfast yet. :P
filmote
(Simon)
January 12, 2018, 11:37pm
#10
Yeah … I did that on my phone (and I have fat fingers). And I have just revised history.
MLXXXp
(Scott)
January 13, 2018, 12:19am
#11
```cpp
```
will hint that you’re enclosing C++
```text
```
will hint that you’re enclosing plain text, so it won’t try to use syntax highlighting.
1 Like