Uhh, guys, I already looked at this problem for some time.
Assuming we're going with Python:
An idea about collisions:
Using masks to check would probably be too slow, so I thought we could do it like this.
Map Wallmasks would be passed at compile time in a special script that checks each pixels and creates a rect there if it is black/opaque/whatever.
This also allows us to scale the maps, which is not easy to do otherwise. Now we just have to scale the surface before drawing.
The string of rects would then be saved and embedded into the .png or even kept as separate file.
It can then be loaded without much problems and without much lag, and suddenly you have rects to collide with instead of masks.
(which, if you only check the rects in the area around the Character, is much faster)
My problem is this:
import os
import glob
import pygame
from load_image import load_image
from pygame.locals import *
surface = pygame.Surface()
path = 'Maps/'
for infile in glob.glob( os.path.join(path, '*_wm.png') ):
image, rect = load_image(infile)
# Loop through all the pixels and create a rect per black pixel
for a in range(0, ???)
There is no built-in function of pygame.Image to determine it's size, so I either have to guess a very large number or get creative.
Ideas?
All, and I mean all the objects we have have rectangular collision masks.
Collision detection is as simple as:
with CollisionRect
{
if point_distance(x, y, other.x, other.y) > size_of_object+a_little_constant
{
continue;
}
else
{
if rect_collide(other, id)
{
reactToCollision()
break;
}
}
}
Written in GMK syntax so that everyone can follow it, if programmed in a compiled language like C++ and packed into a dll, this could run fast as hell.
We don't need more, and this allows us to keep our pixel-based wallmasks.
PS: "CollisionRect" would be every zoomed pixel.