Objekt steckt oft in Solid-Objekte fest

  • Allgemein
  • Objekt steckt oft in Solid-Objekte fest

    Hallole,

    ich habe daran stundelang versucht, das Problem zu lösen, doch irgendwie bringt es mir einfach nicht weiter.
    Das Spieler steckt oft im Solid-Objekte, troz. mit "place_meeting" hat mir auch nicht weitergebracht.
    Weiß einer, woran das liegen könnte?

    Create:

    GML-Quellcode

    1. angle = 0
    2. xscale = 1
    3. xx = 0
    4. yy = 0
    5. spd = 10
    6. yyspeed = 0.4
    7. xxspeed = 0.5
    8. lastkey = 1
    Alles anzeigen


    Step:

    GML-Quellcode

    1. //Image angle
    2. angle = -xx
    3. if xx < 0{
    4. xscale = -1
    5. }else if xx > 0{
    6. xscale = 1
    7. }else{
    8. xscale = lastkey
    9. }
    10. //Control (and collision check for right and left)
    11. x += xx/2
    12. y += yy/2
    13. if keyboard_check(ord('A')){
    14. //left
    15. if place_free(x+1,y){
    16. if -spd < xx{
    17. xx -= xxspeed
    18. }
    19. }else{
    20. xx = 0
    21. }
    22. lastkey = -1
    23. }else if keyboard_check(ord('D')){
    24. //right
    25. if place_free(x+1,y){
    26. if spd > xx{
    27. xx += xxspeed
    28. }
    29. }else{
    30. xx = 0
    31. }
    32. lastkey = 1
    33. }else{
    34. if xx > 0{
    35. xx -= xxspeed
    36. }else if xx < 0{
    37. xx += xxspeed
    38. }else{
    39. xx += 0
    40. }
    41. }
    42. //Collision check (for up and down)
    43. if keyboard_check(ord('A')) or keyboard_check(ord('D')){
    44. //Up
    45. if place_free(x,y-1){
    46. if -spd/2 < yy{
    47. yy -= yyspeed
    48. }
    49. }else{
    50. yy = 0
    51. }
    52. }else{
    53. //Down
    54. if place_free(x,y+1){
    55. if spd/2 > yy{
    56. yy += yyspeed/2
    57. }
    58. }else{
    59. yy = 0
    60. }
    61. }
    Alles anzeigen


    Draw:

    GML-Quellcode

    1. //draw self
    2. draw_sprite_ext(spr_egg,0,x,y,xscale,1,angle,c_white,1)


    Auf Antwort würde ich mich echt freuen!
    Ihr stinkt.
  • Versuch anstelle von:

    GML-Quellcode

    1. if place_free(x+1,y)


    Mal das hier:

    GML-Quellcode

    1. if (place_free(x +xscale * xxspeed,y))



    Wenn das nicht funktioniert liegt es vieleicht auch einfach daran dass du bei links auch
    place_free(x+1,y)

    hast da muss aber:
    place_free(x-1,y)
    hin.


    MFG~
    Imagine taking your usual two century long nap minding your own business when suddenly some cunt wakes you up.
    You tell him to f*ck off of course but just when you finally managed to fall asleep again the same asshole comes knocking again. I'd attack that dick too.
  • DragonXZ schrieb:

    Versuch anstelle von:

    GML-Quellcode

    1. if place_free(x+1,y)


    Mal das hier:

    GML-Quellcode

    1. if (place_free(x +xscale * xxspeed,y))



    Wenn das nicht funktioniert liegt es vieleicht auch einfach daran dass du bei links auch
    place_free(x+1,y)

    hast da muss aber:
    place_free(x-1,y)
    hin.


    MFG~


    Das hat mir auch nicht weitergeholfen. Bei Links habe ich mich vertippt und schon längst gefixt.
    Das hat mir aber weitergeholfen:

    GML-Quellcode

    1. if !place_free(x+1,y) or !place_free(x-1,y){
    2. x = xprevious
    3. xx = 0
    4. }


    Troz. danke für deiner Mühe!
    Ihr stinkt.