Isometrie mit Maussteuerung (Test)

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

OJay

Betreff: Isometrie mit Maussteuerung (Test)

BeitragFr, Feb 06, 2004 16:32
Antworten mit Zitat
Benutzer-Profile anzeigen
ja hallo.

im chat reagiert keiner auf mich, also stell ichs mal hier rein :p

es geht um eine idee, die ich heute auf arbeit hatte. und zwar dreht sich das ganze um eine spielfigur in 2D iso grafik, welche aber direkt mit maus und tastatur zu steuern ist. man kann sich das ähnlich einem ego-shooter vorstellen, nur ohne ego Smile

ich habs ins codearchiv gestellt, weil vielleicht einige den code hilfreich finden in bezug auf: Types, umgang mit sinus/cosinus und wie man einen flammenwerfer gestaltet ^_^

für alle ohne-pix-nix-sauger: http://user.blue-cable.de/ojay/ani_test.PNG
grafiken sind alle gerendert, dienen aber nur als dummies...

hier der link mit allen grafiken: http://user.blue-cable.de/ojay/ani_test.rar (2,2MB)

und hier der code, falls sich jemand nicht die 2mb antun will =D. dann müsst ihr aber grafiken selbst bereitstellen oder rects nehmen ^^


also berichtet mir mal bitte, wie es sich anfühlt! thx


Code: [AUSKLAPPEN]
;//////////////////////////////////////////////////
;// variables deklaration
;//////////////////////////////////////////////////
Const rechts = 205 ;keycodes
Const links  = 203 ;keycodes
Const hoch   = 200 ;keycodes
Const runter = 208 ;keycodes

Global mainx = 320       ;figurstartpunkt
Global mainy = 240       ;figurstartpunkt
Global mainangle = 90    ;figurstartwinkel
Global mainspeed = 0    ;figurstartgeschwindigkeit
Global frame = 1       ;startframe der figur

Global timer = CreateTimer(50)

Dim mainaimrun(12,25)
Dim mainaimstand(12)

Type schuss
   Field x,y,angle
End Type

Type explo
   Field x,y,frame
End Type


;///////////////////////////////////////////////////
;// initialisierung
;///////////////////////////////////////////////////
Graphics 1024,768,16,1
SetBuffer BackBuffer()

ClsColor 128,128,128
HidePointer
AutoMidHandle 1



;////////////////////////////////////////////////////
;// image-caching
;////////////////////////////////////////////////////
; run animation
For i=1 To 12
For j=0 To 25
   If Len(j) < 2 num$ = "0" + j Else num$ = j
   mainaimrun(i,j) = LoadImage("data\main_aim_run\manaimrun_"+i+"_00"+num+".bmp")
   MaskImage mainaimrun(i,j),128,128,128
   ;If mainaimrun(i,j) OK$ = "OK" Else OK$ = "Failed"
   ;Print "Lade: manaimrun_"+i+"_00"+num+".bmp ..... " + OK$
Next
Next


; still animation
For i=1 To 12
   If Len(i) < 2 num$ = "0" + i Else num$ = i
   mainaimstand(i) = LoadImage("data\main_aim_stand\mainaimstand_"+num+"_0000.bmp")
   MaskImage mainaimstand(i),128,128,128
   ;If mainaimstand(i) OK$ = "OK" Else OK$ = "Failed"
   ;Print "Lade: mainaimstand_"+num+"_0000.bmp ..... " + OK$
Next


; zielkreuz
cross = LoadAnimImage ("data\cross.bmp", 25, 25, 0, 1)
;explosion
explo = LoadAnimImage ("data\explo01.bmp", 80, 80, 0, 22)


;///////////////////////////////////////////////////
;// mainloop
;///////////////////////////////////////////////////
Repeat

   Cls

   ;figurbewegung stoppen
   mainspeed = 0
   mainstrafe = 0
   
   ;///////////////////////////////////////////////////
   ;// controls
   ;///////////////////////////////////////////////////
   ;figur drehen
   mainangle = (mainangle + (MouseX() - GraphicsWidth()/2)/4) Mod 360
   MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
   ;winkel prüfen/korrigieren
   If mainangle < 1   mainangle = mainangle + 360
   If mainangle > 360 mainangle = mainangle - 360
   ;strafen
   If KeyDown(rechts) mainstrafe = 90
   If KeyDown(links)  mainstrafe = -90
   ;figur vor/zurueck
   If KeyDown(runter) mainspeed = -4 frame = frame - 1
   If KeyDown(hoch)   mainspeed =  4 frame = frame + 1
   ;framekontrolle
   If frame > 25 frame = 1
   If frame < 1  frame = 25
   ;shooting
   If MouseDown(1)
      s.schuss = New schuss
      s\x = mainx + Cos(mainangle) * 5
      s\y = mainy + Sin(mainangle) * 5
      s\angle = mainangle
   EndIf
   
   ;/////////////////////////////////////////////////////
   ;// position and angle correction
   ;/////////////////////////////////////////////////////
   ;neue position berechnen
   If mainspeed Or mainstrafe
      mainx = mainx + (Cos(mainangle + mainstrafe) * mainspeed)
      mainy = mainy + (Sin(mainangle + mainstrafe) * mainspeed)
   EndIf
   ;zielkreuzposition berechnen
   crossx = mainx + (Cos(mainangle) * (mainspeed + 250))
   crossy = mainy + (Sin(mainangle) * (mainspeed + 250))
   ;drehframe korrigieren
   rotframe = Int(Ceil(mainangle/29)) + 3
   If rotframe < 1  rotframe = rotframe + 12
   If rotframe > 12 rotframe = rotframe - 12
   ;schüsse verarbeiten
   For s.schuss = Each schuss
      s\x = s\x + (Cos(s\angle) * 20)
      s\y = s\y + (Sin(s\angle) * 20)
      ;neue explosion
      e.explo = New explo
      e\x = s\x + Rand(1,5)
      e\y = s\y + Rand(1,5)
      e\frame = 0
      ;kollision innerhalb des bildschirms
      If RectsOverlap(s\x,s\y,1,1,50,50,GraphicsWidth()-100,GraphicsHeight()-100) = False
         Delete s
      EndIf
   Next
   
   ;//////////////////////////////////////////////////////
   ;// drawing
   ;//////////////////////////////////////////////////////
   ; schüsse
   For s.schuss = Each schuss
      Color 255,255,0
      Line s\x, s\y, s\x + (Cos(s\angle) * 5), s\y + (Sin(s\angle) * 5)
      tempangle = s\angle
   Next
   ;explosionen
   For e.explo = Each explo
      If e\frame < 22
         DrawImage explo,e\x,e\y,e\frame
         e\frame = e\frame + Rand(1,2)
      Else
         Delete e
      EndIf
   Next
   ; fadenkreuz
   DrawImage cross,crossx,crossy
   ; figur
   If KeyDown(runter) Or KeyDown(hoch)
      DrawImage mainaimrun(rotframe,frame),mainx,mainy
   Else
      DrawImage mainaimstand(rotframe),mainx,mainy
      frame = 0
   EndIf

   Color 0,0,0
   Text 10,10,"crossangle : " + mainangle + " bulletangle : " + tempangle
   
   Flip

   WaitTimer(timer)

Until KeyHit(1)
End

DC

Sieger des B2D Retro Wettbewerb / Aug 04

BeitragFr, Feb 06, 2004 18:50
Antworten mit Zitat
Benutzer-Profile anzeigen
Hmm naja .. finde das sehr gewöhnungsbedürftig. Dauert immer ne weile bis ich mich dahingedreht habe wo ich hin will .. naja vllt gewöhnt man sich ja dran Smile
Core i5 4670K | 4 x 3,40 GHZ | 16 GB Ram | GeForce GTX 960 | HTC Vive | Win 10 Pro
www.UnrealSoftware.de | www.StrandedOnline.de | www.CS2D.com |
www.CarnageContest.com | www.Stranded3.com

Mandrason

BeitragFr, Feb 06, 2004 21:07
Antworten mit Zitat
Benutzer-Profile anzeigen
geht bei mir nicht(B+)
Irren ist menschlich, und manche Menschen sind Irre

Albert Einstein
 

OJay

BeitragFr, Feb 06, 2004 21:22
Antworten mit Zitat
Benutzer-Profile anzeigen
createtimer() und waittimer() auskommentieren...müsste dir der debugger aber auch enzeigen o-O

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group