Neometron

Member

53

606 Good

• Rank
Member

• Role
Artist
Programmer
• Interests
Art
Audio
Design
DevOps
Education
Production
Programming
QA

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. Implementing 2D World Chunking and World Positions

I'll try to clarify what I was doing in the Render pseudo code. I'll do it twice to show how it works. Round 1: void Render() { .. Get camera position in pixels camera_x = .. camera_y = .. chunk_id[4] = GetCameraChunks( camera_x, camera_y ) Let say the camera's origin is located at 960, 540. camera_x = 960 camera_y = 540 We'll look at the GetCameraChunks. BTW, remember when I said I didn't check my math; I didn't account for off by 1 problem so I forgot to subtract 1 to the maximums. chunk_id[4] GetCameraChunks( camera_x, camera_y ) { min_x = camera_x - SCREEN_HX max_x = camera_x + SCREEN_HX - 1 min_y = camera_y - SCREEN_HY max_y = camera_y + SCREEN_HY - 1 chunk_id[0] = pair< GetChunkCoord( min_x, min_y ) > chunk_id[1] = pair< GetChunkCoord( max_x, min_y ) > chunk_id[2] = pair< GetChunkCoord( min_x, max_y ) > chunk_id[3] = pair< GetChunkCoord( max_x, max_y ) > } min_x = 960 - 960 = 0 max_x = 960 + 960 - 1 = 1919 min_y = 540 - 540 = 0 max_y = 540 + 540 - 1= 1079 We'll also look at what GetChunkCoord does with these values. chunk_x, chunk_y GetChunkCoord( pixel_x, pixel_y) { chunk_x = pixel_x / CHUNK_SIZE chunk_y = pixel_y / CHUNK_SIZE } chunk_x = pixel_x / CHUNK_SIZE = 0 / 3200 = 0 chunk_y = pixel_y / CHUNK_SIZE = 0 / 3200 = 0 chunk_x = pixel_x / CHUNK_SIZE = 1919 / 3200 = 0 chunk_y = pixel_y / CHUNK_SIZE = 0 / 3200 = 0 chunk_x = pixel_x / CHUNK_SIZE = 0 / 3200 = 0 chunk_y = pixel_y / CHUNK_SIZE = 1079 / 3200 = 0 chunk_x = pixel_x / CHUNK_SIZE = 1919 / 3200 = 0 chunk_y = pixel_y / CHUNK_SIZE = 1079 / 3200 = 0 Note that this is normal behavior for division for integer types. So going back to GetCameraChunks: chunk_id[0] = pair< GetChunkCoord( min_x, min_y ) > = pair< 0, 0> chunk_id[1] = pair< GetChunkCoord( max_x, min_y ) > = pair< 0, 0> chunk_id[2] = pair< GetChunkCoord( min_x, max_y ) > = pair< 0, 0> chunk_id[3] = pair< GetChunkCoord( max_x, max_y ) > = pair< 0, 0> I'll skip ahead to this section of the Render function: ..Tile's pixel location in world space world_px = (TILE_SIZE * tile_x) + (chunk.id[x] * CHUNK_SIZE) world_py = (TILE_SIZE * tile_y) + (chunk.id[y] * CHUNK_SIZE) ..Camera's top left px coord in world space camera_px = camera_x - SCREEN_HX camrea_py = camera_y - SCREEN_HY ..Tile's pixel location in screen space tile_px = world_px - camera_px tile_py = world_py - camera_py world_px = (TILE_SIZE * tile_x) + (chunk.id[x] * CHUNK_SIZE) = ( 64 * 0 ) + ( 0 * 3200 ) = 0 world_py = (TILE_SIZE * tile_y) + (chunk.id[y] * CHUNK_SIZE) = ( 64 * 0 ) + ( 0 * 3200 ) = 0 camera_px = camera_x - SCREEN_HX = 960 - 960 = 0 camrea_py = camera_y - SCREEN_HY = 540 - 540 = 0 tile_px = world_px - camera_px = 0 - 0 = 0 tile_py = world_py - camera_py = 0 - 0 = 0 At this point render the tile at tile_px and tile_py which is top left corner of that tile image. Round 2: We moved the camera by 10px in the update function. camera_x += 10 = 960 + 10 = 970 camera_y += 10 = 540 + 10 = 550 GetCameraChunks( 970, 550 ) will yield again 4x pair<0, 0> world_px = (TILE_SIZE * tile_x) + (chunk.id[x] * CHUNK_SIZE) = ( 64 * 0 ) + ( 0 * 3200 ) = 0 world_py = (TILE_SIZE * tile_y) + (chunk.id[y] * CHUNK_SIZE) = ( 64 * 0 ) + ( 0 * 3200 ) = 0 camera_px = camera_x - SCREEN_HX = 970 - 960 = 10 camrea_py = camera_y - SCREEN_HY = 550 - 540 = 10 tile_px = world_px - camera_px = 0 - 10 = -10 tile_py = world_py - camera_py = 0 - 10 = -10 At this point render the tile at tile_px and tile_py which is top left corner of that tile image but partially off the screen. The conclusion is that horizontal and vertical scrolling is built into the formula. Just move the camera an the world will move with it.

3. WorldCubed

These are images as I progress in making my own voxel engine.
4. Week of Awesome III : Part One

It's come near the end of day three for the WoA3, and I want to elaborate on what had happened since the start of the competition. Prior to the competition start: Circumstances broke my team up! I originally planned to work with my daughter and nephew, but they had other obligations this summer break. However, I will not be working alone since I have joined forces with Markypooch in team Pink Elephant. In this team I assumed my role as content creator where as Markypooch is the lead programmer. Day 1: We stayed up late Sunday night, drinking mainly, to wait for the competition's theme "Death is Useful." I find this theme interesting because it can be spun in so many different ways. I also found this theme to be difficult because it can be spun in so many ways. We called it a night and figured that we would have a solid idea later in the day. Evening came, and we still did not have a clue. Day 2: We determined that the game had to be simple, one level, no collisions or physics, and can be programmed while off work hours. While Markypooch was working at his day job, I drafted up a game concept in Blender. He liked it, and it is now game on! Day 3: My nephew may still help with sound effects. I tasked him to make about 30 sfx of various things. Here are screenshots of our level I been working on. Note that these are only renditions using Blender's cycles.

10. Neometron

I haven't been active on GameDev for a while now, so I suppose I'll make my first post. I decided to make the move from programming as a hobby to programming as a profession, so I started my own indie game development business last month named NeoVG.