Array-Probleme
Übersicht

burriBetreff: Array-Probleme |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hallo,
ich möchte Bildvorlagen, per drag and drop auf den Monitor beliebig oft duplizieren. Je nach Auswahl soll die gewählte Bildvorlage dupliziert werden. Dass mit der Bildvorlage wechseln während ich dupliziere, bekomme ich nicht gebacken. Kann ich dafür ein Scriptbeispiel bekommen? Ich hoffe das war verständlich. danke, und viele Grüße burri |
||
![]() |
XeresModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ehrlich gesagt ist das nicht verständlich.
Mit etwas Code könnte man eher erahnen, was du vor hast. |
||
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) |
![]() |
Eingeproggt |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich hab mal n kleies Beispiel für Drag&Drop geschrieben. Ist in ~10Minuten entstanden, also falls da noch Verbesserungen drin wären: Ja, möglich, bitte nicht meckern, es dient ja nur zur Demonstration.
Code: [AUSKLAPPEN] Graphics 800,600,0,2
SetBuffer BackBuffer() Local timer=CreateTimer(50) ;Array erstellen und mit Zufallswerten füllen Dim inventar(9,9) SeedRnd MilliSecs() For x=0 To 9 For y=0 To 9 inventar(x,y)=Rand(0,2) Next Next Repeat ;Mauseingabe speichern für Abfrage mhit=MouseHit(1) ;inventar zeichnen For x=0 To 9 For y=0 To 9 ;Irgendwelche Symbole Select inventar(x,y) Case 0 Rect x*30,y*30,20,20,0 Case 1 Rect x*30,y*30,20,20,1 Case 2 Oval x*30,y*30,20,20,1 End Select ;Mausabfrage If MouseX()>x*30 And MouseX()<x*30+30 And MouseY()>y*30 And MouseY()<y*30+30 Then ;Feld markieren Color 255,0,0 Rect x*30,y*30,30,30,0 Color 255,255,255 ;Mauseingabe abfragen If mhit Then item=inventar(x,y) EndIf EndIf Next Next ;Drag&Drop If MouseDown(1) Then If Not drag Then drag=True Else ;Symbolvorschau an Maus anhängen Select item Case 0 Rect MouseX(),MouseY(),20,20,0 Case 1 Rect MouseX(),MouseY(),20,20,1 Case 2 Oval MouseX(),MouseY(),20,20,1 End Select EndIf Else If drag Then drag=False ;Beim Loslassen Item absetzen If MouseX()/30<=9 And MouseY()/30<=9 Then inventar(MouseX()/30,MouseY()/30)=item EndIf item=-1 EndIf EndIf Flip 0:Cls WaitTimer timer Until KeyHit(1) End mfG, Christoph. |
||
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9 |
burri |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
hallo Christoph, hallo Ceres
das Code-Beispiel von Christoph muss ich mir noch genauer ansehen. Ich erkläre mal was ich programmieren möchte: Einen Editor für ein Tile-based-Game. Dazu habe ich Kacheln als Vorlage. Diese Kacheln benutze ich um ein Weg zu setzen, die Begrenzung des Weges zu setzen und um weitere Objekte wie Bomben oder Feinde zu setzen, so kann ich mir die Spiele-Levels selber bauen. Wenn ich nachdem ich ein paar Weg-Kacheln platziert habe, einen Begrenzungskachel setzen möchte, ändern sich auch die Weg-Kacheln in Begrenzungskacheln mit, soll aber nicht. Ich befürchte dass es durch den Code auch nicht verständlicher wird. Die Kacheln heissen bullets, weil ich den Code mir von den Blitz-Samples gezogen habe. Code: [AUSKLAPPEN] Graphics 800,600,32,1
SetBuffer BackBuffer() Global x=400 ;Auto Anfangsposition Global y=300 Global x2=0 Global y2=0 Global xscroll Global yscroll Global a Global i Global wert=100000 Global ywert Global t max_bullets = 500 Dim bullets(max_bullets,2) Global Auto=LoadImage("car.bmp") ;Auto laden MaskImage Auto,0,0,255 MidHandle Auto Dim bull(20) For a = 1 To 4 bull(a) = LoadImage("player"+a+".bmp") Next Global bullet_num = 0 a=1 Autoauf=CopyImage(Auto) ;Auto drehen Autorechts=CopyImage(Auto) RotateImage Autorechts ,90 Autoab=CopyImage(Auto) RotateImage Autoab ,180 Autolinks=CopyImage(Auto) RotateImage Autolinks ,270 Dim bullets(500,2) While Not KeyHit(1) If KeyDown(203) And y Mod 50=0 Or (x Mod 50<>0 And winkel=270) winkel=270 x=x-10 Auto=Autolinks ElseIf KeyDown(205) And y Mod 50=0 Or (x Mod 50<>0 And winkel=90) winkel=90 x=x+10 Auto=Autorechts ElseIf KeyDown(200) Or (y Mod 50<>0 And winkel=0) winkel= 0 y=y-10 Auto=Autoauf ElseIf KeyDown(208) Or (y Mod 50<>0 And winkel=180) winkel= 180 y=y+10 Auto=Autoab EndIf x2=-x+400 y2=-y+300 xscroll=xscroll+(x2-xscroll)/25 yscroll=yscroll+(y2-yscroll)/25 update_bullets() ;Beginn der Hauptschleife update_player() ;If i>=wert ;a=2 ;EndIf ;If i<wert ;a=1 ;EndIf For t=1 To 4 DrawImage bull(t),0,-40+t*50 If ImagesCollide(bull(a),MouseX(),MouseY(),0,bull(t),0,-40+t*50+25,0) Then a=t:wert=i Next Print i Print a DrawImage bull(a),MouseX(),MouseY() Flip Cls Wend End Function update_player() If MouseHit(1) shoot_bullet() EndIf End Function Function shoot_bullet() bullet_num = bullet_num + 1 If bullet_num > 500 bullet_num = 1 EndIf xwert= MouseX()-xscroll ywert= MouseY()-yscroll If xwert<0 ax=-25 Else ax=25 EndIf If ywert<0 ay=-25 Else ay=25 EndIf bullets(bullet_num,1) = (xwert/50)*50+ax bullets(bullet_num,2) = (ywert/50)*50+ay End Function Function update_bullets() For i=1 To bullet_num bullx=bullets(i,1) bully=bullets(i,2) update_object() DrawImage bull(a),bullx+xscroll,bully+yscroll DrawImage Auto,x+xscroll,y+yscroll Next End Function Function update_object() End Function |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group