Objekte "rausschießen" lassen - Blitz3D

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

 

Kifferopa

Gast

Betreff: Objekte "rausschießen" lassen - Blitz3D

BeitragDo, Mai 05, 2005 14:45
Antworten mit Zitat
Also: Ich will eine Waffe programmieren, die Granaten schießen kann. Granaten fliegen bekanntlich nicht immer vor sich hin sondern landen auch mal wieder auf dem Boden. Das sollte etwa so wie in Unreal Tournament funktionieren. Die FlakGun bei rechter Maustaste. Wenn man hochschießt, fliegt die Granate(oder was auch immer) hoch und wird dabei immer langsamer. Dannach kommt sie wieder runter und wird dabei auch wieder immer schneller. Ich glaube, das funktioniert etwa so wie mit der Sprungphysik, aber wie die funktioniert weiß ich auch nicht Embarassed

Danke schon mal Confused

skey-z

BeitragDo, Mai 05, 2005 15:46
Antworten mit Zitat
Benutzer-Profile anzeigen
da kann ich dir den Tipp geben mal mit Google nach Luftwiederstand, Erdanziehung und Tägheit zu suchen, wird sicher einige Physikseiten geben.

ich könnte es dir auch erklären, aber warum das Rad neu erfinden und es würde einziemlich langer Text werden, ich schau aber mal kurz, ob ich auf anhieb ne gute Seite finde.

[Edit]
hab leider keine anständige Seite gefunden, aber ich habe es dir mal veranschaulicht, welche werte gebraucht werden.

user posted image

hoffe du kannst damit was anfangen
Awards:
Coffee's Monatswettbewerb Feb. 08: 1. Platz
BAC#57: 2. Platz
Twitter

Xaron

BeitragDo, Mai 05, 2005 17:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

folgendes Beispiel ist nicht von mir, dürfte aber recht aufschlußreich sein. Wink

BlitzBasic: [AUSKLAPPEN]

Graphics 800,600,32,2

SetBuffer BackBuffer()

ballx#=100
bally#=480
ballr=20
ballmass=5 ;this is in kg
enginethrust=250 ;this is in newtons
engineburntime = 2 ; this is in seconds
flighttime#=0 ;this is the flight time of the rocket so we can keep track of how long the engines have been burning for
;velocity
speed# = 0 ; this is not needed now
;angle
angle# = 70 ; this is the angle that the engines fire at

;we are going to calculate this shortly
yspeed# = 0
yacceleration# = 0

gravity# = -10 ; this is constant

;we are going to calculate this shortly
xspeed# = 0
xacceleration = 0

;now to calculate the initial x and y speeds based on the firing angle and the speed/velocity

xspeed=speed * Cos(angle)
yspeed=speed * Sin(angle)


time=MilliSecs()
;stop the ball falling through the \"floor\"
While ((Not KeyHit (1)) And bally <= 480)

;this is our loop time calculator
oldtime=time
time=MilliSecs()
t#=Float((time-oldtime))/1000

;add the looptime to flighttime so we know how long we have been flying
flighttime=flighttime+t


;first of all we need to resolve the force of the engines working on the ball in the x and y directions
xforce#=enginethrust * Cos (angle)
yforce#=enginethrust * Sin (angle)

;now we need to work out the accelerations in the x and y directions (F=ma therefore a=F/m)

xacceleration = xforce/ballmass
yacceleration = yforce/ballmass

;not forgetting gravity
yacceleration = yacceleration + gravity

;and finally lets not forget to turn the engines off after 5 seconds
If flighttime > engineburntime Then enginethrust=0

;this is just to show the time on the screen
Text 10,10,\"Program loop time = \"+t+\" seconds\"
Text 10,30,\"xspeed = \"+xspeed
Text 10,50,\"yspeed = \"+yspeed
Text 10,70,\"Flight time = \"+ flighttime
Text 10,90,\"Engine thrust = \" + enginethrust
Line 100,500,700,500
Oval ballx,bally,ballr,ballr

;we are going to accelerate the ball
xspeed=xspeed + xacceleration * t

;changed this formula from gravity to acceleration because we worked out the actual acceleration in the y axis earlier
yspeed=yspeed + yacceleration * t

;now we move the ball according to how much time has passed
ballx=ballx+xspeed*t
;we are using -yspeed because the computer counts lines from top to bottom and we want the ball to travel up the scren not down it
bally=bally-yspeed*t
Flip
Cls
Wend
WaitKey


Gruß - Xaron
Cerberus X - Monkey X Reloaded!

Devils Child

BeitragDo, Mai 05, 2005 19:34
Antworten mit Zitat
Benutzer-Profile anzeigen
macht's dem armen doch nicht komplitzierter als es ist:

Code: [AUSKLAPPEN]

GranateXPos = 0
GranateYPos = 0

;Hauptschleife
while not keyhit(1)
  GranateXPos = GranateXPos + 1
  i = i + 1
  GranateYPos = GranateYPos + i


wend


die x-koordinate steigt konstant, und die y-koordinate linear.
PS: Werte anpassen! Wink
 

Kifferopa

Gast

BeitragDo, Mai 05, 2005 21:02
Antworten mit Zitat
Kewl, vielen Dank an euch alle Very Happy Very Happy Very Happy
 

Kifferopa

Gast

BeitragDo, Mai 05, 2005 21:11
Antworten mit Zitat
Öhm, noch ein Problem Embarassed
Wenn ich zum Beispiel 100 Gegner im Dim-Feld vereinbareBlitzBasic: [AUSKLAPPEN]
Dim Gegner(100)
, dann hab ich 100 Gegner( Laughing ). Wie kann ich die ganzen gegner als Global deklarieren?

thankse
 

Darren

BeitragDo, Mai 05, 2005 21:34
Antworten mit Zitat
Benutzer-Profile anzeigen
erstens hast du 101 gegner und zweitens sind die 101 schon global
MFG Darren
 

BlackTermi

BeitragFr, Mai 06, 2005 0:56
Antworten mit Zitat
Benutzer-Profile anzeigen
So hat er 101 Gegner? ich dachte immer die anzahl die man dort angibt wäre die richtige anzahl, also dim wasweissich(100) sind dann von 0 bis 99. Oder irre ich mich da?

skey-z

BeitragFr, Mai 06, 2005 10:40
Antworten mit Zitat
Benutzer-Profile anzeigen
jep, das war ein irglaube von dir.

dim feld(x) erzeugt Feldeinträge von 0-x, also immer einen mehr als du die x eingibst.
Awards:
Coffee's Monatswettbewerb Feb. 08: 1. Platz
BAC#57: 2. Platz
Twitter
 

Kifferopa

Gast

BeitragSa, Mai 07, 2005 12:07
Antworten mit Zitat
hmm, aber ich hab mal 101 Gegner vereinbart, und auch 101 Meshes geladen. In der Hauptschleife hab ich nix mit den Gegnern angestellt, ich hab nur eine Funktion gemacht, die nach 5 Sekunden alle Gegner aus dem Speicher löscht(mit Freeentity).
Es kam aber eine Fehlermeldung, dass die Gegner nicht existieren!
 

BlackTermi

BeitragSa, Mai 07, 2005 15:43
Antworten mit Zitat
Benutzer-Profile anzeigen
hmm, stimmt denn der pfad von dem du die meshes geladen hast?
 

Kifferopa

Gast

BeitragSo, Mai 08, 2005 14:32
Antworten mit Zitat
Der Pfad stimmt schon, der Panzer wird ja schließlich angezeigt

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group