Jump to content
  • Advertisement
Sign in to follow this  
Joesavage1

OpenGL Simple side scroller with C++ and OpenGL...

This topic is 2446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm a student from the UK, who has a deep knowledge of C++ (and enough of OpenGL to get me along for now) wanting to make a simple 2D platformer.

I am however having a few issues - namely:

1) Dividing the window into easy "blocks" (or dividing the window into a grid type system).
2) Storing the data for all these "blocks" to allow for collision detection and some special effects on "blocks".

For the former, I really don't have a clue. Presumably the easiest way would be to always work in multiples of a certain number and hence always stick to the imaginary "grid", and for the latter I am thinking some kind of multi-dimensional vector (but my problem with multi-dimensional vectors would be that it would make changing individual blocks a bloody pain).

Does anyone have any tips for me, or if possible - answers to my questions?

Thanks In Advance,

Regards,

Joe

Share this post


Link to post
Share on other sites
Advertisement

Hi,

I'm a student from the UK, who has a deep knowledge of C++ (and enough of OpenGL to get me along for now) wanting to make a simple 2D platformer.

I am however having a few issues - namely:

1) Dividing the window into easy "blocks" (or dividing the window into a grid type system).
2) Storing the data for all these "blocks" to allow for collision detection and some special effects on "blocks".

For the former, I really don't have a clue. Presumably the easiest way would be to always work in multiples of a certain number and hence always stick to the imaginary "grid", and for the latter I am thinking some kind of multi-dimensional vector (but my problem with multi-dimensional vectors would be that it would make changing individual blocks a bloody pain).

Does anyone have any tips for me, or if possible - answers to my questions?

Thanks In Advance,

Regards,

Joe


I think the magic keyword you are looking for are Tiles :-)


Share this post


Link to post
Share on other sites
If you want to get the window into tiles, firstly, establish the pixel width and height of the "tiles" or blocks.

Then, figure out what the width and height of the window is and voila, width / width of blocks and height / height of blocks.

There you should have your grid based game ready for you.

Assuming you want to get this done in a rather quick and dirty fashion for practice, why not declare a 2 dimensional array that keeps track of the field and see where that takes you?

Share this post


Link to post
Share on other sites

If you want to get the window into tiles, firstly, establish the pixel width and height of the "tiles" or blocks.

Then, figure out what the width and height of the window is and voila, width / width of blocks and height / height of blocks.

There you should have your grid based game ready for you.

Assuming you want to get this done in a rather quick and dirty fashion for practice, why not declare a 2 dimensional array that keeps track of the field and see where that takes you?


I guess, but what would be the easiest way to store stuff in the multidimensional array?
If I had blocks 64px wide and high, and then the window 800x600, then firstly - the tiles wouldn't completely fit - so I don't quite know how rendering half a block would work, and secondly - would size would I want the array? Let's say that a whole map was 1600x600 (since it's going to side-scroll), would I create an array of size 1600x600 or of 25x10? (And how would I go about adding blocks to this array and then adding really simple, quick collision detection?)

Some further ideas or possibly some pseudocode would be awesome.

Thanks In Advance,

Regards,

Joe

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!