eine frage der bewegung
Übersicht

![]() |
worschtbrotBetreff: eine frage der bewegung |
![]() Antworten mit Zitat ![]() |
---|---|---|
also est mal sry das ich gleich einen sehr langen quelltext posten werde. ![]() allerdings liegt das daran das sich mein fehler irgendwo dort verbirgt.und zwar folgendes: ich möchte gerne ein strategiespiel schreiben und wollte für die einheiten einen allgemeinen ype nehmen allerding funktioniert der move noch nicht so richtig ich weiß aber nicht warum. danke für antworten. ![]() Code: [AUSKLAPPEN] AppTitle "Strategiespiel" Graphics 800,600,16,0 SetBuffer = BackBuffer Type unit Field typ,unit_x,unit_y,goto_x,goto_y,weg_x,weg_y,strecke,schritt,diff_x,diff_y,selected,anim,befehl End Type Global cursor = LoadImage("./gfx/cursor.png") MaskImage cursor,18,127,0 Global tileset = LoadAnimImage("./gfx/tileset.png",40,40,0,300) Global haus1 = LoadAnimImage("./gfx/haupthaus.png",80,80,0,4) MaskImage haus1,18,127,0 MidHandle haus1 Global einheit1 = LoadAnimImage("./gfx/arbeiter.png",20,20,0,12) MaskImage einheit1,18,127,0 MidHandle einheit1 Global goldmine = LoadAnimImage("./gfx/gm.png",80,80,0,2) MaskImage goldmine,18,127,0 MidHandle goldmine Global mann.unit Dim map (20,15) Restore mapdata For y=0 To 14 For x=0 To 19 Read map(x,y) Next Next mann = New unit mann\typ = 1 mann\unit_x = 400 mann\unit_y = 400 mann\goto_x = 100 mann\goto_y = 100 mann\selected = False mann\befehl = False mann\anim = 0 Repeat Cls drawmap() chooseunit() befehl_unit() moveunit() drawunit() DrawImage cursor,MouseX(),MouseY() Flip Until KeyHit(1) Function chooseunit() If MouseHit(1) Then For mann = Each unit If ImagesCollide(cursor,MouseX(),MouseY(),0,einheit1,mann\unit_x,mann\unit_y,mann\anim) Then mann\selected = True Next ElseIf MouseHit(2) For mann = Each unit mann\selected = False Next EndIf End Function Function drawmap() For y = 0 To 14 For x = 0 To 19 DrawImage tileset, x*40, y*40,map(x,y) Next Next End Function Function drawunit() For mann = Each unit If mann\typ = 1 Then If mann\selected = True Then DrawImage einheit1,mann\unit_x,mann\unit_y,mann\anim+7 ElseIf mann\selected = False DrawImage einheit1,mann\unit_x,mann\unit_y,mann\anim EndIf EndIf Next End Function Function befehl_unit() For mann = Each unit If mann\selected = True Then If MouseHit(1) Then mann\befehl = True EndIf Next End Function Function moveunit() For mann = Each unit If mann\befehl = True Then mann\goto_x = MouseX() mann\goto_y = MouseY() mann\weg_x = mann\goto_x - mann\unit_x mann\weg_y = mann\goto_y - mann\unit_y mann\strecke = Sqr (mann\weg_x^2 + mann\weg_y^2) mann\schritt = mann\strecke / 20 If mann\schritt = 0 Then mann\schritt = 1 mann\diff_x = mann\weg_x / mann\schritt mann\diff_y = mann\weg_y / mann\schritt mann\befehl = False EndIf If mann\unit_x = mann\goto_x And mann\unit_y = mann\goto_y Then mann\anim = 0 Else mann\unit_x = mann\unit_x + mann\diff_x mann\unit_y = mann\unit_y + mann\diff_y EndIf Next End Function .mapdata Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 schon mal danke und frohe weihnachten |
||
![]() |
XeresModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
"Funktioniert nicht so richtig" ist keine adäquate Fehlerbeschreibung. Gewöhne dir an zu beschreiben wie es funktionieren soll und was dein code gerade tatsächlich tut.
Setbuffer ![]() MouseX ![]() ![]() ![]() -> Wie kann ich Mausklicks richtig abfragen ? Außerdem einen Timer und Flip ![]() -> Hurra, 100 % Auslastung |
||
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus THERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld) |
![]() |
worschtbrot |
![]() Antworten mit Zitat ![]() |
---|---|---|
ok danke habe die fehler berichtigt dennoch bewegt sich meine einheit (also mann\unit) nicht wenn ich sie ausgewählt habe und dann irgendwo in die gegend klicke.denn eigentlich müsste sie sich doch in die gegebene richtung bewegen oder etwa nicht? | ||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group