opengl game

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

49 Replies - 7051 Views - Last Post: 01 August 2018 - 02:18 PM Rate Topic: -----

#31 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 05 July 2018 - 05:14 PM

yes I meant Vo*t
Was This Post Helpful? 0
  • +
  • -

#32 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 05 July 2018 - 06:41 PM

is this code appropriate for deriving delta time
void delay()
{
	static int prvMs = glutGet(GLUT_ELAPSED_TIME);
	const int curMs = glutGet(GLUT_ELAPSED_TIME);
	const double dt = (curMs - prvMs) / 1000.0;
	prvMs = curMs;
	cout << dt << endl;
}


Was This Post Helpful? 0
  • +
  • -

#33 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 05 July 2018 - 07:08 PM

here id my code for using the position formula
void delay()
{
	float velocity = 20.0f, init_position = 0.0f;
	static int prvMs = glutGet(GLUT_ELAPSED_TIME);
	drawScene_bug_two(position, 10.0f);
	const int curMs = glutGet(GLUT_ELAPSED_TIME);
	const double dt = (curMs - prvMs) / 1000.0;
	prvMs = curMs;
	position = velocity*dt + init_position;
	cout << position << endl;
}


Was This Post Helpful? -2
  • +
  • -

#34 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,944
  • Joined: 12-December 12

Re: opengl game

Posted 06 July 2018 - 12:26 AM

"Is this code appropriate" ... what happens when you run it?

"here id my code" ... and...? What is your question?

The message is not getting through: provide a question each time; explain what you have tried and what happens with any code that you post.
Was This Post Helpful? 0
  • +
  • -

#35 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14928
  • View blog
  • Posts: 59,604
  • Joined: 12-June 08

Re: opengl game

Posted 06 July 2018 - 07:39 AM

Come on now.. don't turn this into your previous threads where it derails itself.

If you want to keep a journal of your progress then use the blog system.
If you have questions then ask them clearly.
Was This Post Helpful? 0
  • +
  • -

#36 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 06 July 2018 - 03:48 PM

well ndc said I should use the position formula to move my sprites, I am using the position formula to move my sprite but it moves the sprite too quickly I want it to move slowly and one sprite width at a time.
Was This Post Helpful? 0
  • +
  • -

#37 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 09 July 2018 - 07:11 PM

void delay()
{
	auto start = chrono::high_resolution_clock::now();
	drawScene_bug_two(move_right, 10.0f);
	auto end = chrono::high_resolution_clock::now();
	chrono::duration<double> diff = end - start;
	cout << diff.count() << endl;
}


well I have setup a timing loop but don't know how to implement it in moving my sprite.
Was This Post Helpful? 0
  • +
  • -

#38 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 11 July 2018 - 03:22 PM

well when I run code in post #37 I get all zeros. I am trying to move my sprite using this timing loop.
Was This Post Helpful? 0
  • +
  • -

#39 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,944
  • Joined: 12-December 12

Re: opengl game

Posted 13 July 2018 - 12:32 AM

@pbivens85 I have hidden your latest post. Unless you have a question to ask do not, as persistently told, post random updates. This forum is not a journal, blog or tweet.

"I want it to..." is not a question.
Was This Post Helpful? 0
  • +
  • -

#40 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 14 July 2018 - 03:30 PM

int time()
{
	using namespace std::chrono;
	auto now = high_resolution_clock::now();
	auto millis = duration_cast<milliseconds>(now.time_since_epoch()).count();
	cout << millis << endl;
	return millis;
}

int refTime = time();

void move(int v)
{
	move_right++;

	if (move_right >= 9.0f)
	{
		move_right = 9.0f;
	}
	drawScene_bug_two(move_right, 10.0f);
	glutPostRedisplay();
	glutTimerFunc(1000, move, 0);
}

void drawScene() {
	glClear(GL_COLOR_BUFFER_BIT);
	bullet();
	drawScene_bug_one(-2.0f, 10.0f);
	if (time() - refTime > 1000)
	{
		move(0);
		refTime += 1000;
	}
	coll_bug_one();
	erase_sprite();
	drawScene_ship_one();
	glutSwapBuffers();
}


well I have done some research on the chrono function and have incorporated it into my game. I am able to print out the time since the last epoch in milliseconds. I am attempting to use the chrono function as a timing loop to move my sprites. is there anyway I can convert the high resolution clock into an integer without using the time since epoch command. as I have researched I don't think there is anyway to accomplish this.
Was This Post Helpful? 0
  • +
  • -

#41 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 17 July 2018 - 06:32 PM

can I get some input on post #40
Was This Post Helpful? 0
  • +
  • -

#42 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 24 July 2018 - 06:58 PM

well I am going to work on my game some more, is there anyway I can use the high resolution clock without using the time since epoch command?
Was This Post Helpful? 0
  • +
  • -

#43 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: opengl game

Posted 28 July 2018 - 07:14 PM

is post #40 too difficult?
Was This Post Helpful? 0
  • +
  • -

#44 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 976
  • View blog
  • Posts: 3,849
  • Joined: 13-June 14

Re: opengl game

Posted 28 July 2018 - 10:59 PM

Why do you need to do everything with integers? Why not just use the standard library classes (i.e. std::time_point or std::duration as appropriate) for the calculations, since they support comparisons and addition/subtraction?
Was This Post Helpful? 0
  • +
  • -

#45 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14928
  • View blog
  • Posts: 59,604
  • Joined: 12-June 08

Re: opengl game

Posted 29 July 2018 - 08:21 AM

FYI - see what everyone else was suggesting:
https://www.opengl.o...833-move-sprite
https://www.gamedev....prite-movement/

View Postpbivens85, on 28 July 2018 - 09:14 PM, said:

is post #40 too difficult?

I would wager folk have just departed the topic.
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4