1
Coding / Problems with platform-engine
« on: February 06, 2011, 07:03:06 pm »
This is probably rather basic and I could just use someone else's engine, but I want to make my own one that I understand fully.
I'm creating a platform-engine using aspects like place_free and gravity. The problems I encounter are as follows:
1.) The player, when reaching a solid block that he can stand on, slows down before touching the block.
2.) When touching a block from the side when in mid-air, the player stops and "sticks" to the wall. If jumping and moving is done right, the player is catapulted into the air.
3.) After the latter of the previously mentioned problem happens, the player, when no key is pressed at all, moves slowly towards the right the entire time. This problem is completely inexplicable to me.
Here are the relevant codes:
obj_block is solid, obj_player isn't.
I hope you can help me out. Thanks for reading and trying in advance!
I'm creating a platform-engine using aspects like place_free and gravity. The problems I encounter are as follows:
1.) The player, when reaching a solid block that he can stand on, slows down before touching the block.
2.) When touching a block from the side when in mid-air, the player stops and "sticks" to the wall. If jumping and moving is done right, the player is catapulted into the air.
3.) After the latter of the previously mentioned problem happens, the player, when no key is pressed at all, moves slowly towards the right the entire time. This problem is completely inexplicable to me.
Here are the relevant codes:
Code: Text
- //Jumping 2
- if place_free(x,y+1){gravity=1.5}else{gravity=0}
- if keyboard_check(vk_space) && place_free(x,y-1) && place_free(x,y+1)=0 vspeed-=20
- //Left and Right
- if keyboard_check(ord('D')) && hspeed>10=false hspeed+=1
- if keyboard_check(ord('D'))=0 and hspeed>0 hspeed-=1
- if keyboard_check(ord('A')) && hspeed<-10=false hspeed-=1
- if keyboard_check(ord('A'))=0 and hspeed<0 hspeed+=1
- //Shoot!
- if mouse_check_button_pressed(mb_left) instance_create(x+16,y+16,obj_bullet)
Code: Text
- if place_free(x,y+vspeed)=false{vspeed=0 move_contact_solid(270,2)}
obj_block is solid, obj_player isn't.
I hope you can help me out. Thanks for reading and trying in advance!