I made a simple game where I have a spaceship that can fire against some enemies..
So far I press the CONTROL key to fire bullets.. The code below (at the end of the post) prevents the auto-fire. That means the spaceship fires a bullet each time the user presses the control key. Even if the user presses once the control key and holds it down then the spaceship fires only one bullet.
I also have an arcade button connected through arduino that I use it to fire bullets. Can anyone tell me how to prevent the auto-fire for this button? I mean for the keyboard keys there are the keyPressed() and keyReleased() but what is going on when you have a button like this?
Thanks!
if (spacebar==true && canfire==1) {
craft.craftMagazine.bullets.add(new Bullet(craft.get_direction()));
canfire=0;
}
void keyPressed() {
switch (keyCode)
{
case CONTROL:
spacebar = true;
break;
}
if (spacebar==true && canfire==1) {
craft.craftMagazine.bullets.add(new Bullet(craft.get_direction()));
canfire=0;
}
I would like something that you probably have done it before so maybe is easy for you to give me some kind of tips..
I have printed fiducials on paper tape..
What I want to do is when I scroll the tape, to get an image scrolling too..
I am trying to figure out how can I map the fiducials on the image. Assume that the tape has 100 fiducials and 1 meter long(3 fts) and the image is about 2000 px width.
The screen is 400 px width. so no more than 4 fiducials can be present at any time..
A friend of mine tried to help me by telling me that I should calculate the distance the fiducials have from the x center of the screen , take the average and then scale/normalize it to 1..
I am not sure if I explained well what I want to do since I am not native English speaker and I do not know if I used the right words..
I would like to ask if there is a way to check when two shapes overlap..
For example let's say that we have two rectangles as shown in the attached image..
In "Case 1" the green rectangle has 4 check points (red dots) in the 4 corners so when it enters the big black rectangle it is easy to verify the overlap.
In "Case 2" the green rectangle is bigger now.. so the the black rectangle passes though the check points and the overlap cannot be verified..
I created a crappy game that the only thing it does is to show an aircraft and by pressing the arrow keys can go up,down,left,right.. and with the space.. shoots!
The problem is that if I press the space bar to shoot while I have the UP button pressed, the aircraft stops, shoots and stays there.. I have to press again the UP button so the aircraft to continue going UP.. When I need to shoot many times, I have to press space and UP button all the time..
For example..
I also use an arcade joystick to play the game(it is connected through arduino ) and this problem does not occur probably because serial sends data continuously while the key variable holds the last button pressed..
So the question is.. Is there anyway to make the aircraft to continue its movement after the space bar is pressed?
I am new to processing and in programing as well so please excuse me if I do not use the right definitions.
What I am trying to do is to load some text in my program.
I create a PFont variable outside the setup() by using this command.
PFont font;
Inside setup() I write this code..
font=loadFont("FatboySlim-24.vlw");
textFont(font);
and in the draw()
text("Hello",60,60);
The problem is the program takes up to 15 seconds to load!
If I comment (from down to top) the lines related to text then when I reach the line "font=loadFont("FatboySlim-24.vlw");" and I comment it the program loads in 1 second!