コード例 #1
0
        void update() {
            shape.move(velocity);

            if(left() < 0) velocity.x = ballVelocity;
            else if(right() > windowWidth) velocity.x = -ballVelocity;

            if(top() < 0) velocity.y = ballVelocity;
            else if (bottom() > windowHeight) velocity.y = -ballVelocity;
        }
コード例 #2
0
ファイル: main2.cpp プロジェクト: FirKys/session_2
	//Обновляем координаты
	void update(){
		Vector2f step = {0,0};
		float testik = test.angle * 3.14159265358979323846 / 180;

		step.x = 0.32f * cos(testik);
		step.y = 0.32f * sin(testik);

		step.y += 0.0015f * time;
		shape.move(step);

		time += 0.1;
	}
コード例 #3
0
ファイル: p4.cpp プロジェクト: Cojacfar/Tutorials
	void update() 
	{ 
		shape.move(velocity); 
		
		// We need to keep the ball "inside the screen".

		// If it's leaving toward the left, we need to set
		// horizontal velocity to a positive value (towards the right).
		if(left() < 0) velocity.x = ballVelocity;

		// Otherwise, if it's leaving towards the right, we need to
		// set horizontal velocity to a negative value (towards the left).
		else if(right() > windowWidth) velocity.x = -ballVelocity;

		// The same idea can be applied for top/bottom collisions.
		if(top() < 0) velocity.y = ballVelocity;
		else if(bottom() > windowHeight) velocity.y = -ballVelocity;
	}
コード例 #4
0
ファイル: p3.cpp プロジェクト: GLax133/Tutorials
	// Let's "update" the ball: move its shape
	// by the current velocity.
	void update() { shape.move(velocity); }