waypoints von ??? |
Ich hab nen Code für Waypoints gemacht. Ist zwar etwas kompliziert für waypoints (denk ich mal), aber ich werds euch trotzdem zeigen ^^ Ist sehr langsam und debug enabled muss AUS sein! [code:1:384c615448] Graphics 640,480,16,1 SetBuffer BackBuffer() reihe=1 ;-----------wenn reihe=1 ist, dann fangen alle punkte beim ersten waypoint an. Sonst bei irgendeinem und gehen der reihe nach weiter .anfang Dim wp(640,480),wpn(10000),wpx(10000),wpy(10000) Dim gx(1000),gy(1000),gwp(1000) gegner_gesammt=100 ;man kann die roten punkte die den waypoints folgen einstellen For a=1 To gegner_gesammt gx(a)=Rnd(1,100) gy(a)=Rnd(1,100) gwp(a)=1 ;der Anfangswaypoint wird gesetzt(der erstplatzierte) Next For x=0 To 640 For y=0 To 480 wp(x,y)=0 ;alle stellen dees bildschrimes werden auf 0 gestellt. Das heisst, es gibt keinen waypoint Next Next rt=0 ; der Modus: rt=0 mann kann WP`s setzen rt=1 die roten punkte folgen den waypoints der reihe nach gesammt=0 Repeat Cls mx=MouseX() my=MouseY() If rt=0 Then ;maker-modus If Mousehit(1) Then If wp(mx,my)=0 Then wp(mx,my)=1 gesammt=gesammt+1 wpn(gesammt)=gesammt wpx(gesammt)=mx wpy(gesammt)=my End If End If Color 0,255,255 For x=0 To 640 For y=0 To 480 If wp(x,y)=1 Then Plot x,y Next Next Color 255,255,0 Plot mx,my If MouseHit(2) Then If gesammt=0 Then Else rt=1 For a=1 To gegner_gesammt If reihe=0 Then gwp(a)=Rnd(1,gesammt) Next End If End If Else If rt=1 Then ;RT-Modus Color 0,255,255 For x=0 To 640 For y=0 To 480 If wp(x,y)=1 Then Plot x,y End If Next Next Color 255,0,0 For a=1 To gegner_gesammt If wpx(gwp(a))=gx(a) And wpy(gwp(a))=gy(a) Then gwp(a)=gwp(a)+1 If gwp(a)>gesammt Then gwp(a)=1 End If End If If wpx(gwp(a))<gx(a) Then gx(a)=gx(a)-1 If wpx(gwp(a))>gx(a) Then gx(a)=gx(a)+1 If wpy(gwp(a))<gy(a) Then gy(a)=gy(a)-1 If wpy(gwp(a))>gy(a) Then gy(a)=gy(a)+1 Plot gx(a),gy(a) Next If MouseHit(2) Then rt=0 For a=1 To gegner_gesammt gx(a)=Rnd(0,100) gy(a)=Rnd(0,100) gwp(a)=1 Next End If End If End If If KeyHit(46) Then Goto anfang ;wenn man C drückt, dann fängt alles von vorne an ^^ Flip Until KeyHit(1) End [/code:1:384c615448] Wenn ihr die Taste C drückt, macht ihr einen neustart des programmes. Mit der linken Maustaste werden die waypoints gesetzt (hellblau punkte), mit der rechten Maustaste werden die punkte gemacht, die den Waypoints folgen. Wenn ihr nochmal die rechte maustaste drückt, könnt ihr weitere waypoints machen. Wenn ihr die variable "reihe", fast zuoberst beim code auf 0 setzt, dann fangen die "gegner" bei irgendeinem Waypoint an und gehen dann weiter. hellblaue punkte: waypoints rote punkte: gegner (Objekte die den waypoints folgen) wenn ein gegner beim letzten waypoint angekommen ist, dann fängt er wieder beim 1. an. mfg |
von ??? |
Nicht schlecht... kannst du dies aber als brauchbare Library umschreiben? |
von ??? |
Nicht schlecht, aber die Bewegungen sind mir etwas zu kantig. Versuch doch mal, weichere Weglinien zu programmieren. |
von ??? |
Außerdem kennen die Typen nur 8 Richtungen. |
von ??? |
nochmal gleiches aussehen, aber andere art: sorry für den unsauberen unoptimierten code auch nur 8 richtungen... aber es ging mir auch um das setzen der waypoints, nicht um die bewegung... (wollte mal types üben) [code:1:27b04d89dd]Graphics 800,600,16,2 SetBuffer BackBuffer() Type type_waypoint Field id Field x,y End Type Type type_point Field id Field x,y End Type Global point.type_point = New type_point Global g_id Global on_way = 0 Repeat Cls If KeyHit(57) Then If on_way = 0 Then start_searching() on_way = 1-on_way End If If on_way = 1 Then search If MouseHit(1) Then g_id = g_id+1 : new_waypoint(g_id,MouseX(),MouseY()) draw_waypoints() test_waypoint(MouseX(),MouseY()) Color 255,255,255 Text 5,10,"Mousekey 1: New Waypoint" Text 5,30,"Mousekey 2: Delete Waypoint" Text 5,55,"Space: Start/Stop Searching" FlushMouse Flip If KeyHit(1) Then End Forever Function new_waypoint(id,x,y) waypoint.type_waypoint = New type_waypoint waypointid = id waypointx = x waypointy = y End Function Function delete_waypoint(id) For waypoint.type_waypoint = Each type_waypoint If waypointid = id Then Delete waypoint For waypoint.type_waypoint = Each type_waypoint If waypointid > id Then waypointid = waypointid-1 Next g_id = g_id-1 Return End If Next End Function Function draw_waypoints() Color 255,255,0 For waypoint.type_waypoint = Each type_waypoint Plot waypointx,waypointy Text waypointx+3,waypointy-13,waypointid Next End Function Function test_waypoint(x,y) Color 255,0,0 For waypoint.type_waypoint = Each type_waypoint If x<waypointx+5 And x>waypointx-5 And y<waypointy+5 And y>waypointy-5 Then Oval waypointx-5,waypointy-5,10,10,0 If MouseHit(2) Then delete_waypoint(waypointid) End If Next End Function Function start_searching() pointx = MouseX() pointy = MouseY() pointid = 1 End Function Function search() For waypoint.type_waypoint = Each type_waypoint If waypointid = pointid Then If pointx<waypointx Then pointx = pointx+1 If pointx>waypointx Then pointx = pointx-1 If pointy<waypointy Then pointy = pointy+1 If pointy>waypointy Then pointy = pointy-1 End If If pointx=waypointx And pointy=waypointy Then pointid = pointid+1 If pointid>g_id Then pointid = 1 Next Color 0,255,0 Plot pointx,pointy End Function [/code:1:27b04d89dd] |