Crouch-Position (Sich ducken)

  • GM 8

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Crouch-Position (Sich ducken)

    Hallo Leutz',
    Ich möchte gerne wenn man 'C' drückt das sich der Spieler duckt.

    Hier der Code von 'obj_player' des Draw Events:

    GML-Quellcode

    1. {
    2. // set the projection
    3. d3d_set_projection(x,y,10, x+cos(direction*pi/180),y-sin(direction*pi/180),10, 0,0,1);
    4. // set color and transparency
    5. draw_set_alpha(1);
    6. draw_set_color(c_white);
    7. // draw floor and ceiling
    8. d3d_draw_floor(0,0,0,room_width,room_height,0,
    9. background_get_texture(texture_floor),32,32);
    10. d3d_draw_floor(0,0,32,room_width,room_height,32,
    11. background_get_texture(texture_ceiling),24,24);
    12. }
    Alles anzeigen

    Und hier der End Step Code:

    GML-Quellcode

    1. {
    2. global.camx = x;
    3. global.camy = y;
    4. global.camsin = sin(direction*pi/180);
    5. global.camcos = cos(direction*pi/180);
    6. }

    Außerdem hätte ich da noch ein Problem...
    Ich habe zwei Waffen (als Sprite). Wenn ich in Room1 gehe habe ich die Shotgun; Aber in Room2 auch ?(
    Aber in Room2 sollte eigentlich die MP5K sein...
    Hier der Code der MP5K...
    Keyboard Space

    GML-Quellcode

    1. {
    2. sound_play(snd_shot);
    3. // determine what you hit
    4. var xx, yy, ii;
    5. xx = global.camx;
    6. yy = global.camy;
    7. repeat (50)
    8. {
    9. xx += 4*global.camcos;
    10. yy -= 4*global.camsin;
    11. ii = instance_position(xx,yy,obj_wall_basic);
    12. if (ii == noone) continue;
    13. break;
    14. }
    15. }
    Alles anzeigen

    DRAW

    GML-Quellcode

    1. {
    2. d3d_set_projection_ortho(0,0,640,480,0);
    3. d3d_set_hidden(false);
    4. draw_sprite_ext(sprite_shotgun,-1,0,480-256,2,2,0,c_white,1);
    5. d3d_set_hidden(true);
    6. }

    ...und von der Shotgun:
    Keyboard SPACE

    GML-Quellcode

    1. {
    2. // check whether you can shoot
    3. if (not can_shoot) exit;
    4. can_shoot = false;
    5. // show the animation and play the sound
    6. image_speed = 0.4;
    7. image_index = 0;
    8. sound_play(snd_shot);
    9. sound_play(snd_reload);
    10. // determine what you hit
    11. var xx, yy, ii;
    12. xx = global.camx;
    13. yy = global.camy;
    14. repeat (50)
    15. {
    16. xx += 4*global.camcos;
    17. yy -= 4*global.camsin;
    18. ii = instance_position(xx,yy,obj_wall_basic);
    19. if (ii == noone) continue;
    20. if (ii.object_index == obj_barrel)
    21. can_shoot = false;
    22. sound_play(snd_complete1)
    23. break;
    24. }
    25. }
    Alles anzeigen

    DRAW

    GML-Quellcode

    1. {
    2. d3d_set_projection_ortho(0,0,640,480,0);
    3. d3d_set_hidden(false);
    4. draw_sprite_ext(sprite_shotgun,-1,0,480-256,2,2,0,c_white,1);
    5. d3d_set_hidden(true);
    6. }


    Ich hoffe ihr könnt mir helfen...
    Danke im voraus wünscht euer Undefined-Account ^^
    ******************************************************************************

    edit by Glowing Orb; Tippfehler im Titel geändert, um Verwechslungsgefahr mit einem anderen englischen Wort zu vermeiden
    Kontakt:
    ICQ: 613678399
    Skype: und3fin3d
    Mail: 3fin3d@fahr-simulator.com
    XFire: und3fin3d9
    Steam: cedric_schmitt
    Website: FS2009-Mods

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Glowing Orb ()

  • *chrchr*

    Wenn du möchtest dass man dir hilft, solltest du ehrlich zu dir selbst sein, dein Problem ist nämlich einfacher als man denken mag. ^.^

    Man schaue sich folgende Zeile an:

    GML-Quellcode

    1. d3d_set_projection(x,y,10, x+cos(direction*pi/180),y-sin(direction*pi/180),10, 0,0,1);

    An zweiter und fünfter Stelle steht jeweils 10 (zfrom, zup), das ist die Höhe, von der dein Spieler guckt. Möchtest du also zwischen mehreren Höhen variiren, z.B. um zu kriechen, musst du nur eine Variable einsetzen. Der Rest ist einfach, hier ein Vorschlag:

    [Create]

    GML-Quellcode

    1. height = 10;


    [Step]

    GML-Quellcode

    1. if(!keyboard_check(vk_control) && height < 10)
    2. height+=1;
    3. if(keyboard_check(vk_control) && height > 5)
    4. height-=1;


    Sprich: Wenn du Strg drückst, wird deine Höhe von 10 auf 5 verringert und andersrum.
  • Danke Moolt,
    Ich fühle mich in diesem Forum wirklich wohl.
    Noch eine Frage:
    Wie ist die Taste 'C' deklariert?
    Etwa so:

    Quellcode

    1. vk_c

    oder anders?
    Danke im voraus
    Undefined
    ************
    Kontakt:
    ICQ: 613678399
    Skype: und3fin3d
    Mail: 3fin3d@fahr-simulator.com
    XFire: und3fin3d9
    Steam: cedric_schmitt
    Website: FS2009-Mods
  • Ich hoffe du hast nicht einfach alles kopiert.
    Die angeprochene Zeile müsste demnach natürlich

    GML-Quellcode

    1. d3d_set_projection(x,y,height, x+cos(direction*pi/180),y-sin(direction*pi/180),height, 0,0,1);


    lauten.