Devlog #2 ~Bit late


Hiya Its me again. yes I'm still alive and working on this project.

 sadly I didn't manage to get a demo version available for Christmas.

But from this disappointment I realised that I was starting to get scope creep as my scope was getting larger the more I thought about what I was gonna get to work on instead of actually getting on and working on it. Basically I've been procrastinating because I've been stuck on one big thing. pixel perfect collision. But I had been re-energized by the holiday and the new year and I've since made some head way.

I tore apart actually how my collision code worked and started by removing mask collision (pixel perfect collision in pygame) and I found that I'd broken my rect collision at some point so no of my collision was working, 

So to rectify my problems I:

1.) Added print statements to say when a collision has happened and whether its horizontal or vertical and print what's returned from the rect.collidelistall function, E.G: (Rect collision V:  [217, 218]) or (Rect collision H:  [1, 5])

2.) Then I displayed the rects of all the tiles that need to have collision (its in red on the photos)

3.)Then I'd solved the problem id commented out a line of code that defines the starting position of the players rect so instead of being where i set the players image it starts at (0,0)*facepalm*.

4.)Then I displayed the masks of the tiles by using the collision_surface and turning it into a mask using the pygame 2 function pygame.mask.from_surface(surface) and then using a bit more code displayed the masks (its green on the photos)

5.) The last change I've made is I've swapped from using pygame.sprite.collide_mask() function which I had to iterate through each different tile the player could collide with to the pygame.sprite.spritecollideany() function which checks all possible collisions between the player and a group of sprites (the collision tiles)

Since I've made all this changes I can visible see whats going on and i get alot of feedback from each movement I make, I've fully rectified the rect collision issue but now my player is colliding but only to the outside of the rect (see image 2) but I'm getting feed back saying both rect and mask collision is working, which I believe means there is a bigger issue with my code which stems from how I sparse my spritesheet and create the individual tiles using code instead of using singular tile images and the alpha of each tile as the mask blitting might not account or display the invisible pixels as from my knowledge on masks they work based on bitmaps and alpha of a pixel (ill delve deeper into this in my next devlog or regular post).

I think that will do for this devlog, i'll be making another devlog/post like things putting my new updated scope all laid out.

thanks

-Whitters 

Comments

Log in with itch.io to leave a comment.

I hope you get the collision working Whitters! Great devlog as always mate, looking forward to seeing your roadmap in the next devlog.