Im Grid einen Schritt zurück

  • GM 8

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

  • Im Grid einen Schritt zurück

    Hallo,
    Ich hab da mal ne Frage.
    Ich hab halt einen 32x32p Character/Objekt welcehr an ein 16x16 grid gebunden ist.
    Rechts in der Map ist ein Schneesturm. Und davor wollte ich Objekte machen,
    welche bei einer Kollision mit dem Player sagen : sorry kannst hier nicht weiter schneesturm blabla :)
    Soweit so gut. Nun soll der Player einen "Schritt" also 16 pixel nach links gehen. sozusagen halt hinweis das es hier wirklich nicht weiter geht .
    Dcoh wie mache ich das. Kann ich nicht sagen gehe ein "grid"-Punkt nach links?

    mfg
  • okay er geht danach nen schritt nach links, doch komischerweise wieder einen kleinen schritt nach links !? d.h. manchmal wird das event dann
    wieder aktiviert und man gerät in eine endlosschleife. aber ich weiß echt nicht wieso er dann wieder nach rechts geht.. hilfe wäre nett^^

    mfg


    edit: geb ich heute abend (10h)

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

  • Dies ist das (lange) Textboxscript (by J-Factor)
    Spoiler anzeigen

    Quellcode

    1. //////////////////////////////////////////////////// //// SCRIPT: textbox(sprite,subimage,text) //// CREATOR: J-Factor //// YEAR: 2005 //// //// DESC: Shows a dialogue textbox. //// //// ARGS: arg0 = sprite //// arg1 = subimage //// arg2 = text //// arg3 = open animation? (true/false) //// [optional] //// ////______________________________________________//// //// J-Factor.COM ////______________________________________________////////////////////////////////////////////////////
    2. // VARIABLES //////////////////////////////
    3. var sprite, subimage, text; // ARGUMENTS //
    4. var x1, y1, x2, y2, sprite_hmargin, sprite_vmargin, text_hmargin, text_vmargin, line_height; // USER VARS //var border_color1, border_color2, border_thickness, fill_color1, fill_color2, text_color, border_alpha1, border_alpha2, fill_alpha1, fill_alpha2; // USER VARS //var background, continue_sprite, continue_key, escape_key, speed_factor, sound, animation_speed, open; // USER VARS //
    5. var c, cx, cy, cc, i, ii, ci, n, m, img, code, w, skip, split; // TEMP VARS //var ix1, iy1, ix2, iy2; // TEMP VARS //var oc, oa; // TEMP VARS //
    6. // ARGUMENTS //////////////////////////////
    7. sprite = argument0;subimage = argument1;text = argument2;open = argument3;
    8. // USER VARIABLES /////////////////////////
    9. x1 = 10; // x1 :: Left x position of textboxy1 = 336; // y1 :: Top-left y position of textboxx2 = room_width - 10; // x2 :: Right x position of textboxy2 = room_height - 10; // y2 :: Bottom y position of textbox
    10. // *** IMPORTANT ***: These are positions on the SCREEN not in the room. You SHOULD NOT use the view variables (view_xview,// view_yview, etc.). Instead, use the view port variables (view_xport, view_yport, etc.).
    11. sprite_hmargin = 10; // sprite_hmargin :: The horizontal margin (or padding) between the sprite and the rest of the textboxsprite_vmargin = 10; // sprite_bmargin :: The vertical margin (or padding) between the sprite and the rest of the textboxtext_hmargin = 20; // text_hmargin :: The horizontal margin between the text and the rest of the textboxtext_vmargin = 20; // text_vmargin :: The vertical margin between the text and the rest of the textboxline_height = 1; // line_height :: Space between lines. Default 1. A value of 2 would give double line spacing.
    12. border_color1 = c_white; // border_color1 :: REGISTERED: Top color of border | UNREGISTERD: Color of borderborder_color2 = c_white; // border_color2 :: REGISTERED: Bottom color of borderborder_thickness = 5; // border_thickness :: How thick the border is. The textbox will always remain within the dimensions // (x1,y1,x2,y2). The border will be within the textbox, squishing the contents.
    13. fill_color1 = c_white; // fill_color1 :: REGISTERED: Top color of textbox | UNREGISTERED: Color of textboxfill_color2 = c_white; // fill_color2 :: REGISTERED: Bottom color of textbox
    14. text_color = c_white; // text_color :: Color of text
    15. border_alpha1 = 0.6; // border_alpha1 :: REGISTERED: Top alpha of border | UNREGISTERED: Alpha of textboxborder_alpha2 = 0.4; // border_alpha1 :: REGISTERED: Bottom alpha of border
    16. fill_alpha1 = 1; // fill_alpha1 :: REGISTERED: Top alpha of textbox | UNREGISTERED: Alpha of textboxfill_alpha2 = 1; // fill_alpha2 :: REGISTERED: Bottom alpha of textbox
    17. background = bck_textbox; // background :: Background to use for the textbox. A value of -1 doesn't use a background // and instead uses the colors + alphas defined above to draw a box. If the background // is too small to fit the dimensions (x1,y1,x2,y2), it is stretched.
    18. // *** NOTES ABOUT BACKGROUNDS ***//// When using backgrounds, only some of the previous attributes have effect.// 1. Borders are no longer used. That means the border_thickness isn't taken into account.// 2. If you are registered:// i. Fill colors are used as blending values (e.g. image_blend).// ii. Fill alphas are still used.
    19. continue_sprite = spr_continue; // continue_sprite :: The continue sprite. When a textbox has finished showing its text // this sprite is displayed in the bottom-right corner of the textbox. // It can be animated.
    20. continue_key = vk_space; // continue_key :: The continue key. The key you press to: // A. Make all the text appear instantly // B. Continue after a textbox (see continue sprite)
    21. escape_key = vk_escape; // escape_key :: The escape key. The key you press to immediately stop a textbox. As // textboxes FREEZE THE GAME, this allows the game to end even if a // textbox is being shown. A value of -1 means there is no escape key. // If you do use it, best set to vk_escape. speed_factor = 1; // speed_factor :: How fast the text appears. E.g. 0.5 = Half speed. Default 1.
    22. sound = snd_type; // sound :: Typing sound. A sound that is played while the text is being typed. Use -1 for no sound.
    23. animation_speed = 0.5; // animation_speed :: Speed of animation (of the portrait). Similiar to image_speed.
    24. // TEMP VARIABLES /////////////////////////
    25. oc = draw_get_color();oa = draw_get_alpha();
    26. split = 0;
    27. // INITIATION /////////////////////////////
    28. window_set_visible(1);
    29. screen_redraw();
    30. line_height *= string_height('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
    31. draw_set_halign(fa_left);draw_set_valign(fa_top);
    32. keyboard_clear(continue_key);
    33. // DRAW BOX ///////////////////////////////
    34. ix1 = x1;iy1 = y1;ix2 = x2;iy2 = y2;
    35. x1 += (x2-x1)/2;y1 += (y2-y1)/2;x2 = x1;y2 = y1;
    36. while (1) { if (open) { x1 = max(x1 - 4,ix1); x2 = min(x2 + 4,ix2); y1 = max(y1 - 2,iy1); y2 = min(y2 + 2,iy2); } else { x1 = ix1; y1 = iy1; x2 = ix2; y2 = iy2; } if (!background_exists(background)) { if (gamemaker_registered) { draw_primitive_begin(pr_trianglelist); // Top border draw_vertex_color(x1,y1,border_color1,border_alpha1); draw_vertex_color(x2,y1,border_color1,border_alpha1); draw_vertex_color(x1,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x2,y1,border_color1,border_alpha1); draw_vertex_color(x1,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x2,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); // Left border draw_vertex_color(x1,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x1,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x1 + border_thickness,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x1,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x1 + border_thickness,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x1 + border_thickness,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); // Right border draw_vertex_color(x2,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x2,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x2 - border_thickness,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x2,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x2 - border_thickness,y1 + border_thickness,merge_color(border_color1,border_color2,border_thickness/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(border_thickness/(y2-y1))); draw_vertex_color(x2 - border_thickness,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); // Bottom border draw_vertex_color(x1,y2,border_color2,border_alpha2); draw_vertex_color(x2,y2,border_color2,border_alpha2); draw_vertex_color(x1,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x2,y2,border_color2,border_alpha2); draw_vertex_color(x2,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x1,y2 - border_thickness,merge_color(border_color1,border_color2,((y2-y1) - border_thickness)/(y2-y1)),border_alpha1 + (border_alpha2 - border_alpha1)*(((y2-y1)-border_thickness)/(y2-y1))); draw_vertex_color(x1 + border_thickness,y1 + border_thickness,fill_color1,fill_alpha1); draw_vertex_color(x2 - border_thickness,y1 + border_thickness,fill_color1,fill_alpha1); draw_vertex_color(x1 + border_thickness,y2 - border_thickness,fill_color2,fill_alpha2); draw_vertex_color(x1 + border_thickness,y2 - border_thickness,fill_color2,fill_alpha2); draw_vertex_color(x2 - border_thickness,y1 + border_thickness,fill_color1,fill_alpha1); draw_vertex_color(x2 - border_thickness,y2 - border_thickness,fill_color2,fill_alpha2); draw_primitive_end(); } else { draw_set_color(border_color1); draw_set_alpha(border_alpha1); draw_rectangle(x1,y1,x2,y1 + border_thickness,0); draw_rectangle(x1,y1 + border_thickness,x1 + border_thickness,y2 - border_thickness,0); draw_rectangle(x2,y1 + border_thickness,x2 - border_thickness,y2 - border_thickness,0); draw_rectangle(x1,y2 - border_thickness,x2,y2,0); draw_set_color(fill_color1); draw_set_alpha(fill_alpha1); draw_rectangle(x1 + border_thickness,y1 + border_thickness,x2 - border_thickness,y2 - border_thickness,0); } } else { if (gamemaker_registered) { draw_primitive_begin_texture(pr_trianglelist,background_get_texture(background)); draw_vertex_texture_color(x1,y1,0,0,fill_color1,fill_alpha1); draw_vertex_texture_color(x2,y1,texture_get_width(background_get_texture(background)),0,fill_color1,fill_alpha1); draw_vertex_texture_color(x1,y2,0,texture_get_height(background_get_texture(background)),fill_color2,fill_alpha2); draw_vertex_texture_color(x1,y2,0,texture_get_height(background_get_texture(background)),fill_color2,fill_alpha2); draw_vertex_texture_color(x2,y1,texture_get_width(background_get_texture(background)),0,fill_color1,fill_alpha1); draw_vertex_texture_color(x2,y2,texture_get_width(background_get_texture(background)),texture_get_height(background_get_texture(background)),fill_color2,fill_alpha2); draw_primitive_end(); } else { draw_background_stretched(background,x1,y1,x2-x1,y2-y1); } } if (open) { screen_refresh(); sleep(5); } if (y1 == iy1) && (y2 == iy2) && (x1 == ix1) && (x2 == ix2) break; }
    37. draw_set_alpha(1);
    38. if (sprite_exists(sprite)) { x1 += sprite_hmargin; if (subimage <> -1) draw_sprite(sprite,subimage,x1,y1 + sprite_vmargin) else img = 0; x1 += sprite_get_width(sprite); }
    39. x1 += text_hmargin;y1 += text_vmargin;x2 -= text_hmargin;y2 -= text_vmargin;
    40. cx = x1;cy = y1;cc = text_color;
    41. m = 0;
    42. i = 1;
    43. skip = 0;
    44. // DRAW TEXT //////////////////////////////
    45. while (1) { io_handle(); if (escape_key <> -1) if (keyboard_check(escape_key)) exit;
    46. // DRAW ANIMATED PORTRAIT // if (subimage == -1) if (sprite_exists(sprite)) { draw_sprite(sprite,floor(img),x1 - text_hmargin - sprite_get_width(sprite),y1 - text_vmargin + sprite_vmargin); img += animation_speed; if (floor(img) >= sprite_get_number(sprite)) img = 0; } c = string_char_at(text,i); // ANALYSE CURRENT CHARACTER // if (c == '\') { if (string_char_at(text,i+1) == '#') or (string_char_at(text,i+1) == '[') or (string_char_at(text,i+1) == '|') { i += 1; if (i > string_length(text)) break; continue; } } else // IF LINE-BREAK CHARACTER if (c == '#') { if (string_char_at(text,i-1) <> '\') { cy += line_height; cx = x1; i += 1; if (i > string_length(text)) break; sleep(80); continue; } else c = '\#'; } else // IF THE START OF A TAG if (c == '[') { if (string_char_at(text,i-1) == '\') { c = '\' + c; } else { code = ''; i += 1; c = string_char_at(text,i); while (c <> ']') { code += c; i += 1; if (i > string_length(text)) break; c = string_char_at(text,i); } if (c == ']') cc = execute_string('return ' + code); i += 1; if (i > string_length(text)) break; continue; } } else // IF PAUSE CHARACTER if (c == '|') { if (string_char_at(text,i-1) <> '\') { i += 1; if (i > string_length(text)) break; sleep(80); continue; } } // IF BEGINNING OF NEW WORD // if ((string_char_at(text,i - 1) == ' ') or (string_char_at(text,i - 1) == '-')) or ((string_char_at(text,i - 1) == '#') && (string_char_at(text,i - 2) <> '\')) or (i == 1) { // CHECK WIDTH // w = 0; ii = i; n = 0; ci = c; while ((ci <> ' ') && (ci <> '-')) { if (ci == '[') n = 1; if ((ci == '\') && (string_char_at(text,ii + 1) == '#')) { ii += 1; if (ii > string_length(text)) break; continue; } if (ci == '#') { if (string_char_at(text,ii - 1) == '\') ci = '\' + ci else break; } if (!n) && (ci <> '\') w += string_width(ci); if (cx + w > x2) break; ii += 1; if (ii > string_length(text)) break; ci = string_char_at(text,ii); if (ci == ']') n = 0; } // IF, CURRENT X + WIDTH OF NEW WORD > EDGE OF TEXTBOX, GO DOWN A LINE if (cx + w > x2) { if (x1 + w <= x2) { cy += line_height; cx = x1; } else // LONG ("unbreakable") WORD WRAPPING // text = string_copy(text,1,ii-1) + '#' + string_copy(text,ii,string_length(text)-ii+1); } } if ((cy + line_height*2 >= y2 - sprite_get_height(continue_sprite)) && (!m)) { x2 -= sprite_get_width(continue_sprite); m = 1; } if (cy + line_height > y2) { split = 1; break; } if (keyboard_check(continue_key)) skip = 1; if (!skip) if ((sound_exists(sound)) && (c <> ' ')) sound_play(sound); draw_set_color(cc); draw_text(cx,cy,c); cx += string_width(c); i += 1; if (i > string_length(text)) break; if (!skip) { screen_refresh(); sleep(40*speed_factor); } }
    47. ii = 0;n = 0;
    48. if (!m) x2 -= sprite_get_width(continue_sprite);
    49. if (sprite_exists(sprite)) draw_sprite(sprite,0,x1 - text_hmargin - sprite_get_width(sprite),y1 - text_vmargin + sprite_vmargin);
    50. while (1) { io_handle(); if (escape_key <> -1) if (keyboard_check(escape_key)) exit; if ((keyboard_check(continue_key)) && (n)) break; if (!keyboard_check(continue_key)) n = 1; draw_sprite(continue_sprite,floor(ii),x2,y2 - sprite_get_height(continue_sprite)); ii += 1; if (floor(ii) >= sprite_get_number(continue_sprite)) ii = 0; screen_refresh(); sleep(40*speed_factor); }
    51. draw_set_color(oc);draw_set_alpha(oa);
    52. if (split) textbox(sprite,subimage,string_delete(text,1,i-1));
    Alles anzeigen



    bei dem collide with txt_schneesturm (dem objekt ,welches berührt werden muss um die aktion auszulösen)
    habe ich folgendes drinne:

    zu erst change sprite into player_walk_left


    danach das:

    GML-Quellcode

    1. textbox(spr_portrait,0,'(Dort tobt ein gewaltiger Blizzardsturm. Ich würde meine Existenz ...blabla blub.)');

    um den textbox script auszulösen

    und zum schluss:

    GML-Quellcode

    1. x-=32 //würd aber 32 eher empfehlen



    Ich hoffe jemnad kann damit etwas anfangen und würde mich sehr über Hilfe freuen.

    mfg UA