Total Überfragt: Kollosionskontrolle funktioniert nicht??
Übersicht

![]() |
satzzeichenBetreff: Total Überfragt: Kollosionskontrolle funktioniert nicht?? |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi Leute ich habe eine einfache Kolossionskontrolle in einem meiner Projekte eingebaut.
If ImagesOverlap(maus, MouseX(), MouseY(), tanksold_player, tanksold_x%, 50) And MouseHit(1) Then money% = 0 Allerdings naja wenn ich dann Versuche auf das Bild tanksoldat_player zu klicken klappts einfach nicht! Habe 30 mins nach nem Fehler gesucht und nixmehr gefunden?!?!?!Achja, das ganze steht auf 1 Zeile!(Habs auch mit der Endif Variante probiert ging auchned) Danke, hoffe auf Hilfe! |
||
![]() |
Rob_ |
![]() Antworten mit Zitat ![]() |
---|---|---|
Lass den ganzencode rüberwachen ![]() So kann man viel sagen z.b das bei deinem tank die y coordinate vielleicht falsch ist, wie gesagt lieber mal den ganzen code rüber wachsen. |
||
AMD Athlon 64 3500+ | Infineon 1 GB DDR RAM | nVidia Geforce 7800 GTX |
![]() |
simi |
![]() Antworten mit Zitat ![]() |
---|---|---|
oder hast du schon vorher einmal MouseHit abgefragt??
Wenn ja, dann speichere Mousehit am Anfang in einer Variable, und frage dann die ab...... |
||
![]() |
satzzeichen |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hmm Mousehit wird vorher schonmal abgefragt aber wieso sollte das denn nicht 2 mal hinternander gehen? ist das nen bug??
code is bisl gröser lol Global player_x = 400 Global player_y = 300 Global enemy_x = 0 Global enemy_y = 0 Global geld_butt_on$ = True Global day_butt_on$ = True Global small_butt_on$ = True Global money% = 500 Global time_small_day% = 0 Global time_day% = 0 Global time_month% = 0 Global time_year% = 0 Global new_mission$ = True Global end_fight$ = False Global tanksold_x% = 50 Graphics 800, 600, 32;, 1 SetBuffer BackBuffer() game_sound=LoadSound ("rocksymph.wav") PlaySound game_sound arial_big=LoadFont ("Arial", 36, True, False, False) arial_small=LoadFont ("Arial", 20, False, False, False) hintergrund= LoadImage("hintergrund.bmp") player= LoadImage("soldat.bmp") enemy= LoadImage("enemysoldier.bmp") geld_butt= LoadImage("geld.bmp") armybase= LoadImage("armybase.bmp") day= LoadImage("day.bmp") small_butt= LoadImage("small.bmp") letter= LoadImage("letter.bmp") MaskImage enemy, 222,222,222 MaskImage armybase, 222,222,222 SeedRnd MilliSecs() random_enemy() ;-----RANDOM_CALCULATION-----; Function random_enemy() enemy_x = Rnd(21,779) enemy_y = Rnd(32,368) End Function ;-----BEGINN_MAINLOOP-----; Repeat Cls TileBlock hintergrund, 0, 0 Color 0, 0, 0 SetFont arial_big Text 315, 268, "Anakreon" enemy_event(enemy, player) button(player, geld_butt, arial_small, day, small_butt, letter) buildings(armybase) player_event(player) research_time() Flip Until KeyHit(1) ;----END_MAINLOOP-----; ;----PLAYER_EVENT-----: Function player_event(player) If KeyDown(200) Then player_y = player_y - 2 time_small_day% = time_small_day% + 1 EndIf If KeyDown(203) Then player_x = player_x - 2 time_small_day% = time_small_day% + 1 EndIf If KeyDown(205) Then player_x = player_x + 2 time_small_day% = time_small_day% + 1 EndIf If KeyDown(208) Then player_y = player_y + 2 time_small_day% = time_small_day% + 1 EndIf If player_x < 0 Then player_x = 0 If player_x > 770 Then player_x = 770 If player_y < 0 Then player_y = 0 If player_y > 570 Then player_y = 570 DrawImage player, player_x, player_y End Function ;-----ENEMY_EVENT----; Function enemy_event(enemy, player) DrawImage enemy, enemy_x, enemy_y If ImagesOverlap(player, player_x, player_y, enemy, enemy_x, enemy_y) Then fight_enemy(player, enemy) End Function ;-----BUTTONS-----; Function button(player, geld_butt, arial_small, day, small_butt, letter) If ImagesOverlap(player, player_x, player_y, geld_butt, 0, 0) Then geld_butt_on$ = False Else geld_butt_on$ = True EndIf If ImagesOverlap(player, player_x, player_y, day, 260, 0) Then day_butt_on$ = False Else day_butt_on$ = True EndIf If ImagesOverlap(player, player_x, player_y, small_butt, 200, 0) Then small_butt_on$ = False Else small_butt_on$ = True EndIf If geld_butt_on$ = True Then DrawImage geld_butt, 0, 0 Color 0, 255, 255 SetFont arial_small Text 100, 6.5, money% EndIf If day_butt_on$ = True Then DrawImage day, 260, 0 Color 0, 255, 255 SetFont arial_small Text 330, 6.5, time_year% Text 450, 6.5, time_month% Text 560, 6.5, time_day% EndIf If small_butt_on$ = True Then DrawImage small_butt, 200, 0 If new_mission$ = True Then DrawImage letter, 204, 3 EndIf End Function ;-----BUILDINGS-----; Function buildings(armybase) DrawImage armybase, 200, 200 DrawImage armybase, 450, 350 End Function ;-----FIGHT_ENEMY-----; Function fight_enemy(player, enemy) If ImagesOverlap(player, player_x, player_y, enemy, enemy_x, enemy_y) Then battle= LoadImage("battleb.bmp") maus= LoadImage("maus.bmp") flee= LoadImage("flee.bmp") tanksold_enemy= LoadImage("tanksold_enemy.bmp") sold_enemy= LoadImage("sold_enemy.bmp") hubi_enemy= LoadImage("hubi_enemy.bmp") tanksold_player= LoadImage("tanksold_player.bmp") sold_player= LoadImage("sold_player.bmp") hubi_player= LoadImage("hubi_player.bmp") MaskImage tanksold_player, 255, 255, 255 MaskImage sold_player, 255, 255, 255 MaskImage hubi_player, 255, 255, 255 MaskImage maus, 255, 255, 255 MaskImage tanksold_enemy, 255, 255, 255 MaskImage sold_enemy, 255, 255, 255 MaskImage hubi_enemy, 255, 255, 255 Repeat Cls end_fight$ = False DrawImage battle, 0, 0 DrawImage tanksold_enemy, 600, 50 DrawImage sold_enemy, 600, 226 DrawImage hubi_enemy, 600, 425 DrawImage tanksold_player, tanksold_x%, 50 DrawImage sold_player, 50, 225 DrawImage hubi_player, 50, 425 DrawImage flee, 340, 550 mouse_OnOff(maus) If ImagesOverlap(maus, MouseX(), MouseY(), flee, 340, 550) And MouseHit(1) Then end_fight$ = True EndIf If ImagesOverlap(maus, MouseX(), MouseY(), tanksold_player, tanksold_x%, 50) And MouseHit(1) Then money% = 0 EndIf Flip Until end_fight$ = True EndIf random_enemy() End Function ;-----RESEARCH_TIME-----; Function research_time() If time_small_day% > 10 Then time_day% = time_day% + 1 time_small_day% = 0 EndIf If time_day% > 31 Then time_day% = 0 time_month% = time_month% + 1 EndIf If time_month% > 12 Then time_month% = 0 time_year% = time_year% + 1 EndIf End Function ;-----MOUSE_ONOFF-----; Function mouse_OnOff(maus) DrawImage maus, MouseX(), MouseY() End Function |
||
![]() |
simi |
![]() Antworten mit Zitat ![]() |
---|---|---|
Nein,
kein Bug ![]() Mousehit gibt die Anzahl klicke seit dem letzten Aufruf zurück. Wenn du das jetzt kurz nacheinenader aufrufst, wurde natürlich nicht wieder geklickt, in dieser kurzen Zeit.... |
||
![]() |
Rob_ |
![]() Antworten mit Zitat ![]() |
---|---|---|
![]() Also ich hab nicht alles angeguckt aber wie ich sehe gibts viele schleifen? Und vielleicht functions , ich krig kopfschmerzen davon ![]() also mach mal in einer hauptschleife mh = mousehit(1) und dann fragst du ab if mh=1 then blabla. |
||
AMD Athlon 64 3500+ | Infineon 1 GB DDR RAM | nVidia Geforce 7800 GTX |
![]() |
satzzeichen |
![]() Antworten mit Zitat ![]() |
---|---|---|
Gut werds so machen! Danke ![]() Achja wieso Spagetthicode??? Is ja nu wirklich keiner alles fein Sortiert etc. ![]() Programmiere nichtnur BB deswegen bin ich soviele Funktionen gewöhnt gg komme gut damit zurecht. (A L L E S is besser als Goto...) |
||
![]() |
satzzeichen |
![]() Antworten mit Zitat ![]() |
---|---|---|
Könntet ihr mir das vieleicht doch nochmal direkt am code erklären? Irgendwie klappt das bei mir einfach nicht ![]() Repeat Cls end_fight$ = False DrawImage battle, 0, 0 DrawImage tanksold_enemy, 600, 50 DrawImage sold_enemy, 600, 226 DrawImage hubi_enemy, 600, 425 DrawImage tanksold_player, tanksold_x%, 50 DrawImage sold_player, 50, 225 DrawImage hubi_player, 50, 425 DrawImage flee, 340, 550 mouse_OnOff(maus) If ImagesOverlap(maus, MouseX(), MouseY(), flee, 340, 550) And MouseHit(1) Then end_fight$ = True EndIf If ImagesOverlap(maus, MouseX(), MouseY(), tanksold_player, tanksold_x%, 50) And MouseHit(1) Then money% = 0 EndIf Flip Until end_fight$ = True EndIf Ich will einfach nur das in dem untermenu das das hier ja ist die 2 Buttons funktionieren. Wäre sehr erfreut wenn ihr mir die betreffende Stelle mal umschreiben könntet oder mir das ganze genau erklärt! PS -> habs jetzt auch alleine hinbekommen trotzdem danke! |
||
![]() |
Alfadur |
![]() Antworten mit Zitat ![]() |
---|---|---|
dennoch ein tipp : booleans sind wahrheitswerte, also nur 1 oder 0... und keine strings ... ! | ||
A Cray is the only computer that runs an endless loop in less than four hours. |
![]() |
Hubsi |
![]() Antworten mit Zitat ![]() |
---|---|---|
BlitzBasic: [AUSKLAPPEN] mh=MouseHit(1)So wars gemeint ![]() |
||
Den ganzen Doag im Bett umanandflagga und iaz daherkema und meine Hendl`n fressn... |
![]() |
Rob_ |
![]() Antworten mit Zitat ![]() |
---|---|---|
..::: hatte hier was flasches gepostet :::.. Sorry | ||
AMD Athlon 64 3500+ | Infineon 1 GB DDR RAM | nVidia Geforce 7800 GTX |
![]() |
Devils Child |
![]() Antworten mit Zitat ![]() |
---|---|---|
probier mal das:
Code: [AUSKLAPPEN] ;x ist die imagexposition ;y ist die imageyposition if mousex() > x and mouseyx() < x + imagewidth(soldat) and mousey() > y and mousey() < y + imageheight(soldat) and mousehit(1) then ;soldat angeklickt. endif |
||
![]() |
satzzeichen |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wiegesgat hatte das probem schon gelöst gg | ||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group