Lost Password?


Go Back   CodeCall Programming Forum > Software Development > General Programming > Programming Theory

Programming Theory Discuss programming theory, algorithm efficiency, logic, and other any other category where math and computer science overlap.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-2007, 12:58 PM
Maurice_Z Maurice_Z is offline
Learning Programmer
 
Join Date: Nov 2007
Location: Poland
Posts: 35
Rep Power: 4
Maurice_Z is on a distinguished road
Send a message via ICQ to Maurice_Z Send a message via AIM to Maurice_Z Send a message via MSN to Maurice_Z Send a message via Yahoo to Maurice_Z
Default Complex Platformer Engine

I've been working on this project for a while already. Everything seemed fine, unless my friend, who volunteers as GFX maker, showed his creativity by making Not Square blocks. And By accident I've noticed this thing:


(If you didn't notice, the shoot considers the diagonal wall as a square block, in other words the collision isn't precise)
Looks terrible, doesn't it?
And well, I've decided that I have to recode the whole engine. I started it yesterday, and got quite much already, while I found another, unsolvable this time, problem.

But first of all:
I was wondering what will be the best method. I decided, that Player collision with walls will be Grid-Then-Pixel based. I couldn't think of any better name. How does it work?
Basically, whole level is divided into 32x30 blocks. This is the main grid. Every block is a Square with a 25 Pixels long edge. And every Block type has its code, like:
Code:
G_Block_Code[5,0]  ="x                        "
G_Block_Code[5,1]  ="xx                       "
G_Block_Code[5,2]  ="xxx                      "
G_Block_Code[5,3]  ="xxxx                     "
G_Block_Code[5,4]  ="xxxxx                    "
G_Block_Code[5,5]  ="xxxxxx                   "
G_Block_Code[5,6]  ="xxxxxxx                  "
G_Block_Code[5,7]  ="xxxxxxxx                 "
G_Block_Code[5,8]  ="xxxxxxxxx                "
G_Block_Code[5,9]  ="xxxxxxxxxx               "
G_Block_Code[5,10] ="xxxxxxxxxxx              "
G_Block_Code[5,11] ="xxxxxxxxxxxx             "
G_Block_Code[5,12] ="xxxxxxxxxxxxx            "
G_Block_Code[5,13] ="xxxxxxxxxxxxxx           "
G_Block_Code[5,14] ="xxxxxxxxxxxxxxx          "
G_Block_Code[5,15] ="xxxxxxxxxxxxxxxx         "
G_Block_Code[5,16] ="xxxxxxxxxxxxxxxxx        "
G_Block_Code[5,17] ="xxxxxxxxxxxxxxxxxx       "
G_Block_Code[5,18] ="xxxxxxxxxxxxxxxxxxx      "
G_Block_Code[5,19] ="xxxxxxxxxxxxxxxxxxxx     "
G_Block_Code[5,20] ="xxxxxxxxxxxxxxxxxxxxx    "
G_Block_Code[5,21] ="xxxxxxxxxxxxxxxxxxxxxx   "
G_Block_Code[5,22] ="xxxxxxxxxxxxxxxxxxxxxxx  "
G_Block_Code[5,23] ="xxxxxxxxxxxxxxxxxxxxxxxx "
G_Block_Code[5,24] ="xxxxxxxxxxxxxxxxxxxxxxxxx"
I have to explain how collision detection for player works, before I can continue.
Player has 4 collision points, in every corner one. So when I go left, It detects for collision in positions (X,Y) and (X,Y+10) (11 is player height). When I fall, pixels at (X,Y+10) and (X+10,Y+10). In other words, only those corners which should be are tested for collision.
So, how the whole checking collision looks:
First I determine in which grid position lies needed pixel (Floor(corner_x/25),Floor(corner_y/25)). If that thing is an empty space, nothing changes. But if there is a wall, it did further checking. It returned position IN TILE (The position relative to current grid square's X and Y position) which is "Something Mod 25". Then the position was compared with code we have above, and determined the ending position. Sounds a bit complicated, but I'm not able to describe it better.
Anyway, this algorithm led to two mayor problems:


A - Here we have situation where player falls too fast and lands too low. In first step player will be pushed to the level as if the diagonal didn't exist. Then in second step it will "Notice" the DiagWall and end up in proper place. This can be quite easily fixed with few loops. But in the end it will be too slow to be acceptable. I think.

B - The player falls on a wall so that the Collision Points don't detect the wall and it looks bad, and works bad. I have no solution for this.

So, I was wondering if you have any good advice about it.
I also though it would be nice and fast to use N's engine, but understanding how it works is too hard for me (If it was better documented then maybe).
And last thing, if you know links to some good Platformer Engines (Not bare code, unless well commented) or some articles/ideas on how to make it good.

Thanks in advance!

Last edited by Maurice_Z; 12-05-2007 at 03:51 PM. Reason: Fixed image link
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get a good positon on a search engine mandriva Search Engine Optimization 10 05-09-2008 03:28 PM
Wikisari Search Engine xtraze Search Engine Optimization 0 01-08-2007 08:13 AM
Write a Java chess engine, a blog Zlaire Java Help 5 01-06-2007 06:08 AM
AOL opens video search engine to developers Lop General Programming 0 09-19-2006 02:26 PM


All times are GMT -5. The time now is 08:45 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads