Gui und Canvas (RPG EDITOR PROB.)
Übersicht

![]() |
Mathias-KwiatkowskiBetreff: Gui und Canvas (RPG EDITOR PROB.) |
![]() Antworten mit Zitat ![]() |
---|---|---|
also ich hab ein folgendes prob. hier erst mal die hauptschleife
Code: [AUSKLAPPEN] Repeat
Select WaitEvent() Case EVENT_GADGETACTION ' interacted with gadget DoGadgetAction() Case EVENT_WINDOWCLOSE ' close gadget Exit End Select SetGraphics CanvasGraphics(canvas_world) Cls DrawTileMap() SuperSelectoRRR() Cam_Control() Flip Forever in cam control wird geprüft ob man pfeil rechts links oben unten drückt , wenn das gedrückt wird soll sich die map scrollen, aber der prüft ja nochnimmals ob gedrückt wurde warum? hier der gesammte code: Code: [AUSKLAPPEN] AppTitle = "MapEditor"
Global worldeditor:TGadget Global canvas_world:TGadget Global listbox_ed:TGadget worldeditor = CreateWindow("MapEditor", 0, 00, 1024, 800, Desktop(), WINDOW_TITLEBAR | WINDOW_RESIZABLE) canvas_world=CreateCanvas(0,0,800,600,worldeditor) SetGadgetLayout canvas_world,1,2,1,2 listbox_ed = CreateListBox(808, 0, 200, 600, worldeditor) Global tsetz:TIconStrip = LoadIconStrip("tsetz.png") SetGadgetIconStrip(listbox_ed, tsetz) For t = 0 To 224 AddGadgetItem listbox_ed, "ICO = " + t, 0, t Next SetGadgetLayout listbox_ed,1,2,1,2 Global Icons:TImage = LoadAnimImage("tsetz.png", 32, 32, 0, 225) Global Ebene:Int = 0 Global Tile:Int = 0 Global XPos:Int = 0 Global YPos:Int = 0 Global cam_x Global cam_y Global cam_speed = 32 Global tilemap:Int[1000, 1000, 9] Global max_x:Int = 25 Global max_y:Int = 19 Global maux:Int Global mauy:Int Global lab0:TGadget = CreateLabel("Ebene: " + Ebene, 10, 625, 350, 12, worldeditor) Global lab1:TGadget = CreateLabel("Aktuelles Tile: " + Tile, 10, 625 + 13, 350, 12, worldeditor) Global lab2:TGadget = CreateLabel("Position X: " + XPos, 10, 625 + 13 * 2, 350, 12, worldeditor) Global lab3:TGadget = CreateLabel("Position Y: " + yPos, 10, 625 + 13 * 3, 350, 12, worldeditor) '-mainloop-------------------------------------------------------------- CreateTimer 60 NeueMap() Repeat Select WaitEvent() Case EVENT_GADGETACTION ' interacted with gadget 'DoGadgetAction() Case EVENT_WINDOWCLOSE ' close gadget Exit End Select SetGraphics CanvasGraphics(canvas_world) Cls DrawTileMap() SuperSelectoRRR() Cam_Control() Flip Forever Function DrawTileMap() cam_x_div = cam_x / 32 cam_y_div = cam_y / 32 'Malt 21*16 Tiles statt 100*100 Tiles For x = cam_x_div To cam_x_div + max_x For y = cam_y_div To cam_y_div + max_y For i = 0 To 8 DrawImage Icons, x * 32 - cam_x, y * 32 - cam_y, tilemap(x, y, i) Next Next Next End Function Function SuperSelectoRRR() xt = ((MouseX() + cam_x) / 32) yt = ((MouseY() + cam_y) / 32) x = xt * 32 - cam_x y = yt * 32 - cam_y SetGadgetText (lab2, "Position X: " + xt) SetGadgetText (lab3, "Position Y: " + yt) xt = ((MouseX() + cam_x) / 32) yt = ((MouseY() + cam_y) / 32) x = xt * 32 - cam_x y = yt * 32 - cam_y If MouseDown(1) Then tilemap[xt, yt, Ebene] = Tile EndIf If MouseDown(2) Then tilemap[xt, yt, Ebene] = 0 End If End Function Function NeueMap() For x = 0 To 999 For y = 0 To 999 For z = 0 To 8 tilemap(x, y, z) = Rnd(15) Next Next Next End Function Function Cam_Control() 'Die Kamera wird hier mit Pfeiltasten gesteuert, Q und A beeinflussen den Speed If KeyDown(KEY_LEFT) Then cam_x = cam_x - cam_speed - cam_speed End If If KeyDown(KEY_RIGHT) Then cam_x = cam_x + cam_speed + cam_speed End If If KeyDown(KEY_UP) Then cam_y = cam_y - cam_speed - cam_speed End If If KeyDown(KEY_DOWN) Then cam_y = cam_y + cam_speed + cam_speed End If If move=1 Then EndIf 'Hier wird verhindert, dass die Kamera ausserhalb der Map gerät If cam_x < 0 Then cam_x = 0 If cam_y < 0 Then cam_y = 0 If cam_x > 999 * 32 - max_x * 32 Then cam_x = 999 * 32 - max_x * 32 If cam_y > 999 * 32 - max_y * 32 Then cam_y = 999 * 32 - max_y * 32 End Function |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
weil du es nie überprüfst?
Seh da kein Handling für EVENT_Mousexy und EVENT_Keyxy sprich dein program checkts net. Den regulären Code kannst du rauswerfen, der ist polling, net event basierend. Den könnte man zwar zum leben erwecken, würde ich aber aus mindestens 2 Gründen nicht tun: 1. wird dann der vorteil vom eventbasierenden code gleich wieder aufgehoben, kannst dir waitevent also auch gleich sparen. 2. der event wird so oder so nur existieren wenn der canvas aktiv ist. also kannst du es auch da oben prüfen oder in nem eventhook |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group