Moin zusammen =D
Gibt es in GLBasic eigentlich eine Möglichkeit eine gezeichnete Linie (DRAWLINE) mit nem Sprite oder einer anderen Linie bzw. Rechteck kollidieren zu lassen? Würde mir bei meinem aktuellen Projekt schon ganz gut helfen^^
Gruß
Fauk
I'm not totally sure what you mean but try this one:
http://www.glbasic.com/showroom.php?game=AC3DPoly&site=games&lang=en (http://www.glbasic.com/showroom.php?game=AC3DPoly&site=games&lang=en)
I want to realize scrolling with DRAWLINE.
(http://www.pictureupload.de/originals/pictures/281108121532_Projekt.jpg)
In this picture you see 4 lines (DRAWLINE) and a cursor in the middle. I want that when the cursor touches one of the 4 lines then should the scrolling start. My particular problem is, that I have to do this with variables, because the screensize is not constant. My idea to fix this problem ist to work with DRAWLINE.
FUNCTION Scrolling:
Map_X_Gesamt = (BOUNDS(Karte[],0))*32 //X-Koordinate vom Kartenarray ablesen
Map_Y_Gesamt = (BOUNDS(Karte[],1))*32 //Y-Koordinate vom Kartenarray ablesen
GETSCREENSIZE Screen_X,Screen_Y //Auflösung einlesen
DRAWLINE (Screen_X - 32) ,(Screen_Y - 32) ,(Screen_X - Screen_X + 32) ,(Screen_Y - 32) ,RGB(255,0,0) //Unten
DRAWLINE (Screen_X - 32) ,(Screen_Y - Screen_Y + 32) ,(Screen_X - Screen_X + 32) ,(Screen_Y - Screen_Y + 32) ,RGB(255,0,0) //Oben
DRAWLINE (Screen_X - Screen_X + 32) ,(Screen_Y - 32) ,(Screen_X - Screen_X + 32) ,(Screen_Y - Screen_Y + 32) ,RGB(255,0,0) //Links
DRAWLINE (Screen_X - 32) ,(Screen_Y - 32) ,(Screen_X - 32) ,(Screen_Y - Screen_Y + 32) ,RGB(255,0,0) //Rechts
ENDFUNCTION
But I have no idea how to check if the cursor collides with the lines^^ The link you gave me is good but only for scrolling it makes no sense to include the whole thing xD I need only something like BOXCOLL for a LINE->SPRITE collision^^
In deinem Fall: Mach ein BOXCOLL Innen-aussen. Wenn's kollidiert, bist Du _nicht_ am Rand!
[en]
In your case: do a BOXCOLL with inner vs outer box. If it collides, you're _not_ at the border.
(http://www.pictureupload.de/originals/pictures/281108134502_Projekt.jpg)
Das war es, danke Gernot :good:
hehe es kann so einfach sein :D
Do you want to scroll similar to strategy games where you move the mouse to the edge of the screen to scroll around? Then all you need to do is keep track of how big the screen is (GETSCREENSIZE sx, sy) and then do some if's to check if the cursor is close to 0 or to sx or sy. This also gives you WHICH edge you are close to so you know what direction to scroll. Let me know if I'm misunderstanding something :-)
Ich poste hier mal meinen Code, falls es noch jemand brauchen kann =D
FUNCTION Scrolling:
Map_X_Gesamt = (BOUNDS(Karte[],0))*32 //X-Koordinate vom Kartenarray ablesen
Map_Y_Gesamt = (BOUNDS(Karte[],1))*32 //Y-Koordinate vom Kartenarray ablesen
GETSCREENSIZE Screen_X,Screen_Y //Auflösung einlesen
// -----> Optische Kontrolllinien <----- //
DRAWLINE (Screen_X - 32),(Screen_Y - 32),32,(Screen_Y - 32) ,RGB(255,0,0) //Unten
DRAWLINE (Screen_X - 32),32,32,32 ,RGB(255,0,0) //Oben
DRAWLINE 32,(Screen_Y - 32),32,32 ,RGB(255,0,0) //Links
DRAWLINE (Screen_X - 32),(Screen_Y - 32),(Screen_X - 32),32 ,RGB(255,0,0) //Rechts
// -----> Kollisionsüberprüfung <----- //
Check_Kollision_Links = BOXCOLL ((Cursor_X*32),(Cursor_Y*32),32,32 ,0,0,32,Screen_Y)
Check_Kollision_Rechts = BOXCOLL ((Cursor_X*32),(Cursor_Y*32),32,32 ,Screen_X,0,(-32),Screen_Y)
Check_Kollision_Oben = BOXCOLL ((Cursor_X*32),(Cursor_Y*32),32,32 ,0,0,Screen_X,32)
Check_Kollision_Unten = BOXCOLL ((Cursor_X*32),(Cursor_Y*32),32,32 ,0,Screen_Y,Screen_X,(-32))
// -----> Kollision <----- //
IF Check_Kollision_Links = TRUE AND KEY (Taste_Links) = TRUE AND Timer < GETTIMERALL()
Timer = GETTIMERALL() + 100
INC Scroll_X ,32
ENDIF
IF Check_Kollision_Rechts = TRUE AND KEY (Taste_Rechts) = TRUE AND Timer < GETTIMERALL()
Timer = GETTIMERALL() + 100
DEC Scroll_X ,32
ENDIF
IF Check_Kollision_Oben = TRUE AND KEY (Taste_Oben) = TRUE AND Timer < GETTIMERALL()
Timer = GETTIMERALL() + 100
INC Scroll_Y ,32
ENDIF
IF Check_Kollision_Unten = TRUE AND KEY (Taste_Unten) = TRUE AND Timer < GETTIMERALL()
Timer = GETTIMERALL() + 100
DEC Scroll_Y ,32
ENDIF
// -----> Mapbegrenzungen <----- //
IF Scroll_X >= 0 THEN Scroll_X = 0
IF Scroll_Y >= 0 THEN Scroll_Y = 0
IF Scroll_X <= (-(Map_X_Gesamt - Screen_X)) THEN Scroll_X = (-(Map_X_Gesamt - Screen_X))
IF Scroll_Y <= (-(Map_Y_Gesamt - Screen_Y)) THEN Scroll_Y = (-(Map_Y_Gesamt - Screen_Y))
ENDFUNCTION
Funktioniert mit allen Auflösungen und allen Mapgrößen.