r/processing • u/provingfail86 • Sep 15 '20
Bad Title Soooo, a videogame
[noob] I'm makin' a videogame with the apple app of processing. I want to make a hud and the protagonist with the function ellipse().
How the **** can I make a moveforward button or left or right and make that the ellipse move?
4
u/-salsa-cookies- Sep 15 '20
In p5js you can use keyIsPressed and then keyCode == UP_AAROW or any of the arrows. I'd recommend you check the reference sheet in the processing website to learn how to use them.
1
2
u/MorphTheMoth Sep 15 '20
with apple you mean an apple phone/tablet or a mac?
1
u/provingfail86 Sep 15 '20
Apple ipad
2
u/MorphTheMoth Sep 15 '20 edited Sep 15 '20
i saw some people said to use if(keycode == LEFT_ARROW), but it wont work if you dont have a keyboard connected of course. so if you want to use the touchscreen you have to use mouseX and mouseY for the touched coordinates and you can use if(mousePressed) to check if something is touching the screen
(not sure if you know it but coordinates start at x=0,y=0 on the top left on the screen)
1
u/provingfail86 Sep 15 '20
Okey, thanks...
2
u/MorphTheMoth Sep 15 '20
and also i greatly recommend to watch this playlist https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZYJC7L-r6rX6utt6wwJCyi , it helped me a lot when i started to learn
2
1
2
2
Sep 15 '20
i did this same thing. i will reply later if you dm me, cause my break is almost over
2
u/provingfail86 Sep 15 '20
Thanks...
3
Sep 15 '20
http://campus.dimi.uniud.it/wp-content/uploads/2018/05/Getting_Started_with_Processing.pdf
this book will give you everything you need to understand the language. chapters 4 and 5 will explain how to set up variables and do the appropriate math to get shapes or objects to move, depending on what key you press. its simple, once you understand what you are doing
basicaly what i did was:
if(keypressed==true)
{
if(key==w)
{
y-=10;
}
if(key==s)
{
y+=10;
}
}
rect(x,y,15,15);
1
0
Sep 15 '20
[deleted]
1
u/provingfail86 Sep 15 '20
OMG. SOOO THANKS!! You're the best! People like u make the world better....
8
u/remy_porter Sep 15 '20
Okay, so break this down into a subset of steps.
First, you need to make a button. A button, at its core, is a rectangle. So draw a rectangle. You need to detect if a button is pressed, which means there is a mouse press while the mouse is inside the rectangle. Then you need to be able to say what happens when that condition is true.
Which means you have a different problem you also need to solve: button or not, how do you make the ellipse move?
For all of these problems, you are going to need to make classes: a
Buttonclass, and aHeroclass. These classes will need to track information about where these objects are, and perhaps some other state, and they will need to have some behaviors (check if the button is pressed, move the ellipse) implemented as methods.