Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void timer1_Tick(object sender, EventArgs e)
- {
- RegisterBlocks();
- }
- void playerSkin()
- {
- if (!jump && !right && !left)
- {
- player.Image = Image.FromFile("stand.png");
- }
- }
- void checkColision(PictureBox block)
- {
- //Colision
- //Right
- if (player.Left + player.Width >= block.Left && block.Left + player.Width > player.Left && player.Top < block.Top && player.Bottom > block.Bottom)
- {
- right = false;
- player.Left = block.Left - player.Width;
- }
- //Left
- if (block.Right + player.Width >= player.Right && block.Right + player.Width <= player.Right + block.Width && block.Bottom + block.Height >= player.Bottom + 5 && block.Top <= player.Top)
- {
- left = false;
- player.Left = block.Right;
- }
- //Top
- if (player.Left + player.Width > block.Left && player.Left < block.Left + block.Width && player.Top + player.Height >= block.Top && player.Top < block.Top)
- {
- player.Top = block.Top - player.Height;
- force = 0;
- onObject = true;
- jump = false;
- }
- else
- {
- onObject = false;
- }
- //Bottom
- if (player.Left + player.Width > block.Left && player.Left < block.Left + block.Width && player.Bottom > block.Bottom && player.Bottom <= block.Bottom + player.Height + 3)
- {
- force = -1;
- }
- }
- void RegisterBlocks()
- {
- checkColision(b3);
- checkColision(b1);
- checkColision(b2);
- checkColision(block); // This one is the only block that is not 'jumpy'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement