Encountering a problem with the ordering of pushing and poping matrices.
I'm trying to re-create the movement of the ship from asteroids. I was trying to make it so it moves along the Y axis with easing, and seeing as the rotate function is awesome, steering will be handled by rotating the axis. However here in lies the problem. I need to move the rotation point with the image of the ship, however for it to move in the right direction it needs to be rotated, but I need the move to move the rotation point.......
Is there a work around for this? or do I need to wide it and start again.
Just quickly here is the movement of the ship:
class pShip { int xPone, yPone, xPtwo, yPtwo, xPthree, yPthree; float mover, rotateControl, posY; float multiplier = .1;
pShip(int _xPone, int _yPone, int _xPtwo, int _yPtwo, int _xPthree, int _yPthree) { xPone = _xPone; yPone = _yPone; xPtwo = _xPtwo; yPtwo = _yPtwo; xPthree = _xPthree; yPthree = _yPthree;
}
void draw_pShip() {
translate x, y by width/2 & hightt/2
move drawing
transate by yPone and set rotation to //rotate(rotationControl);
Problem encountered is it either rotates and only moves off the top of the screen or it moves onlong the rotated axis but when a rotation is required it jumps because the rotation point hasn't moved.
-thanks
(I know my easing is wrong, I am making a key array to sort this)
I am trying to get a function that checks the colour of a shape, and if it's red value is above z, and another shape is inside it, then the shape is reset to position x and y.
I am having really trouble writing this and have been struggling for several days. Code that peers are telling me to try seem to do nothing, here's the latest
void resetCheck()
{
loadPixels();
redValue = get (int(PosX), int(PosY));
if (red(redValue) >= redThreshold)
{
PosX = 25;
PosY = 25;
}
}
The only problem with this I see is that PosX and PosY are the center positions of a yellow circle, and not of the flashing squares behind them that I want the red value of,
this function is contained in a class and the flashing square in another class
Working on a fairly simple top view game and have come to writing in the players character movement, which I thougt would be simple. I was looking for a simple w, s, a, d movement system, but it appears to be running into issues. Is there a way of putting in the void keypressed function into a class? If that makes sence.
I've been able to write a simple prog. that moves an ellipse around the screen but in my larger program would like to include it in a class, so later I can add a case statement to use 1 or 2 players using the w, s, a, d and arrow keys as movement
I woud like to store a shape I have drawn in a class into an array, so later when it comes to drawing them (having them fill the screen) I don't have to go out and keep declaring a "bah1... 2... 3... 4... ect = new blah" but I'm not sure how to go about storing the 'shape' in an array. I think I might just be having a mental block atm, but here is my class:
class dangerBlock
{
float reda = 0;
float redb = 0;
float redValue;
float greenValue;
dangerBlock()
{
for (int i = 0; i < block.length; i++)
{
block[i] = drawBlock;
}
}
void colourChange()
{
float r = random(.009, .1);
reda = reda + r;
redb = cos (reda);
redValue = redb;
greenValue = redb;
redValue = map (redValue, -1, 1, 0, 255);
greenValue = map (greenValue, 1, -1, 0, 255);
}
I have a program that appends 2 arrays when you click and drag the mouse.
One array logs the mouseX
The other logs the mouseY
I have been able to get it to save btoh arrays into 2 seperate CSV files like so:
String[] s1 = new String[Xpos.length]; for(int i = 0; i < Xpos.length; i ++) { s1[i] = str(Xpos[i]); } saveStrings("Xpoints.csv", s1); String[] s2 = new String[Ypos.length]; for(int i = 0; i < Ypos.length; i ++) { s2[i] = str(Ypos[i]); } saveStrings("Ypoints.csv", s2);
I know need it to load these files from the CSV's, however I am unsure how I would reverse the procces. I also think I will need to append the arrays for every value in the CSV as both arrays are declared as such:
int[] Xpos = new int [0];
int[] Ypos = new int [0];
I'm trying to make a bouncing ball change colours whe it hits a wall it will bounce off, however I keep encountering an error that reports "Cannot convert float to boolean". I just can not see what the error is refering too.
I have written a bi of code that basically makes a ball bouns between 1/10 and 9/10 of the width and height of the screen. The reason why it's 1/10 and 9/10 is because I want 4 paddles that will 'track' the ball so it looks like it is bouncing off the paddles. However when I tried coding the relative x and y points of the lines I was using for the paddles they follow their own paths and are out of sinc with the ball.
Is there a way of getting the 'center point' of the circle as it moves along the x and y axis. I'm after something like this
line(width/10, "x value of the center of the circle - shapesize/2", width/10 "x value of the center of the circle + shapesize/2");