Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
for (int i=0; i < distanz; i++) { float r = (float) (i / (distanz-1)); float x = getWaffe().getX() + r * (targetX - getWaffe().getX()); float y = getWaffe().getY() + r * (targetY - getWaffe().getY()); getWaffe().setX(x); getWaffe().setY(y); } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
float alpha; float fx; float fy; int throwposition; public void condition() { // Wurf if(throwing) { // Position auf dem Richtungsvektor alpha = (float) (throwposition/(distance-1)); // Richtungsvektor fx = Main.getThorshammer().getX() + alpha * (targetX - Main.getThorshammer().getX()); fy = Main.getThorshammer().getY() + alpha * (targetY - Main.getThorshammer().getY()); // Koordinaten setzten Main.getThorshammer().setX(fx); Main.getThorshammer().setY(fy); // Wurfgeschwindigkeut throwposition += throwspeed; // Abbruchbedingung, wenn der Hammer die Distanz zurückgelegt hat if(alpha>=1) { // Wurf auf false setzten throwing = false; // Wurfposition wieder zurücksetzen throwposition = 0; } } } |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
// Diese drei Werte müssen natürlich irgendwie gegeben sein Vektor ziel; Vektor start; float speed; Vektor direction = ziel - start; direction = direction.normalize(); // hier wird normalisiert. Die Länge wird also auf 1 gebracht. Wie das funktioniert zeigt dir ein Mathebuch, Google, oder eine Frage in diesem Forum Vektor position = start + direction * speed * time; |
Werbeanzeige