I'm not going to pretend to be a hot girl. Will you still help me?
in
Programming Questions
•
1 year ago
Hello,
I appreciate this forum is not for 'doing your work' but I need a simple
example to grasp the
task. I'm finding this incredibly difficult and I'm close to dropping out.
I sat in the lab today thinking 'I don't belong here'.
I'm a first year Com/Sci student (third week) and we've been asked to set up: a projectile game using variables =
The features of the game should be:
- The game is about moving a ball.
- When you hold the mouse button down the display should be as if you were pulling a catapault. The position of the catapault should be a fixed place on the screen. As you move the mouse, the ball should follow it but be linked to the catapault by a line representing the catapault elastic.
- When you release the mouse, the ball should start moving with a velocity that should depend on where you had dragged the ball relative to the catapault. The direction should be going from the ball position to the catapault. The speed should depend on how far away you had pulled the ball.
- The ball should carry on moving after it has been released, and fall under gravity
My lecturer is very difficult to approach - he did not cover mouseDrag etc.
This is what he's given us as a base I have so far:
int posX=0;
float posY=0;
int r = 0;
int speedX = 1;
float speedY = 0;
void setup()
{
size(400, 400);
//posX = 0;
}
void draw()
{
background(255);
strokeWeight(3);
stroke(r, 0, 0);
point(posX, posY);
r += 1;
posX = posX + speedX;
posY = posY + speedY;
speedY += 0.2;
}
void mousePressed()
{
posX = 0;
posY = 0;
}
1. how do I fix the point's position?
2. How do I get the mouse to manipulate the point? And revert it back to it's
original position?
and whatever help and hints you can give. If I use your code I will reference
it.
1