View Single Post
Old 05 September 2016, 21:04   #20
AlgoRythmic
Registered User
 
Join Date: Jun 2016
Location: MiggyLand
Age: 44
Posts: 13
Hi!
Someone suggested elsewhere in this forum that you can go for higher number of objects if you draw half the bobs in one frame and the rest of them the other frame.

Well I tried to do that with your code and I think I got it working properly.
Granted it's not that smooth but maybe you or somebody else could find a use for it or maybe even improve upon it. Personally I don't mind it that much and I would be interested to know how it fares on a real machine since I don't currently own one.

Anyway here it is:


Code:
WBStartup ; makes the program startable from icons and autoboot

DEFTYPE .w

;--------------------------
BitMap 3,260,220,3   ; temporary bitmap for image loading

LoadBitMap 3,"DemoGFX/SORenemy2.iff"
GetaShape 20,0,10,40,71
LoadBitMap 3,"DemoGFX/SORaxel2.iff"
GetaShape 21,0,10,39,73
LoadBitMap 3,"DemoGFX/SORtile2.iff"
GetaShape 23,0,10,16,16
Free BitMap 3
;--------------------------

LoadPalette 0,"DemoGFX/DemoPaletteSORf8b8.iff"

PalRGB 0,0,0,0,3  ; turns color 0 (transparent background color)
                  ; to blueish black

#UP = $11
#DOWN = $21
#LEFT = $20
#RIGHT = $22
#KEY_2 = $2
#KEY_1 = $1

#ZERO = 0
#ONE = 1

#PLAYER_SPEED = 3
#PLAYER_RIGHT_BOUNDARY = 260
#PLAYER_BOTTOM_BOUNDARY = 120

#ENEMY_SPEED = 2
#ENEMY_LEFT_BOUNDARY = 3
#ENEMY_RIGHT_BOUNDARY = 250

#MAXIMUM_BOBS = 49

;TTTTTTTTTTTTTTTTTTTTTTTT

NEWTYPE .ship     ; although they arent really ships
x.w
y.w
animframe.b
direction.b
displacement.b
name.b
End NEWTYPE

Dim List go.ship(100)



;ResetList go()
;a = FirstItem(go())
;a = AddItem (go())   ; dummy item, always have one at the start
                     ; of all lists to avoid problems

;TTTTTTTTTTTTTTTTTTTTTTTTT


;--------------------

VWait 250 ; waits 5 seconds before BLITZing the Operating System
BLITZ
BlitzKeys On

Slice 0,44,320,256,$fffa,6,8,16,448,448

; single playfied = $fff8
; dual playfield  = $fffa

Use Palette 0

BitMap 3,448,384,3   ; 3 bitplane BACK PLAYFIELD

BitMap 0,448,384,3   ; 3 bitplane FRONT PLAYFIELD
BitMap 1,448,384,3   ; with two bitmaps for double buffering

Queue 0,50           ; But we use Queues instead of Buffers
Queue 1,50           ; So we have 2 Queues for 2 Bitmaps

buf.b  = 0           ; buffer and bitmap counters
bmap.b = 0           ; notice that we will call the Queues
                     ; with the name "buf", for sake of
                     ; clarity

Use BitMap 0         ; cleans bitmaps
Cls
Use BitMap 1
Cls

Gosub LevelBuild

ShowB 3,0,0 ; shows bitmap 0 in back playfield
ShowF 0,0,0 ; shows bitmap 1 in front playfield


.variables

x.w = 0
y.w = 0
drawcounter.w = 1
p.w = 0

PL1_X.w = 0  ; player xy
PL1_Y.w = 0

a.w = 0      ; helper variables
b.w = 0
c.w = 0
d.w = 0
e.w = 0
f.w = 0
g.w = 0
t.w = 0

yesx.b=0
yesy.b=0
enemiesonscreen.b=1

skipcounter.b = 0
moveclock.w = 0



t = 20


.mainloop

Use BitMap buf

;OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
Repeat

VWait


If skip_me_first.b
  ShowF buf,#ZERO,#ZERO
  buf = #ONE - buf
  Use BitMap buf        ; swaps the Bitmap where objects
  UnQueue buf
EndIf


skip_me_first = #ONE - skip_me_first

;skipcounter = 1 - skipcounter
;If skipcounter>1 Then skipcounter=0

;moveclock+1
;If moveclock>200 Then moveclock=0


Gosub KeyboardRead


;VVVVVVVV
;VVVVVVVV


;DOUBLE BUFFER WITH 2 QUEUES
;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ

         ; empties Queues 1 and 2 at their turn

;bmap = 1 - bmap
                       ; are drawn this frame

;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ


;BOB DRAW
;----------------------------------------------
;----------------------------------------------

 ; enemy draw


ResetList go()




 ;WWWWWWWWWWWWWWWWWWWWWWWWWWWWW
 ;While NextItem (go())



skip_again.b = skip_me_first


For objects.b = #ZERO To enemiesonscreen - #ONE

  If go()\x < #ENEMY_LEFT_BOUNDARY Then go()\displacement = -go()\displacement

  If go()\x > #ENEMY_RIGHT_BOUNDARY Then go()\displacement = -go()\displacement


   go()\x + go()\displacement


   skip_again = #ONE - skip_again

   If skip_again
   QBlit buf,t,go()\x,go()\y
   EndIf

   NextItem go()







Next objects

  ;----------------------------

;

 ;Wend
 ;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

;----------------------------------------------
;----------------------------------------------

 ; Player draw
 ;-------------------------
 If skip_me_first
 QBlit buf,21,PL1_X,PL1_Y
 EndIf
 ;-------------------------

;----------------------------------------------
;----------------------------------------------


;SSSSSSSSSSSS

;ShowB 3,0,0
;SSSSSSSSSSSS



Until RawStatus($45) ; ESC
;OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO


Goto EndProgram

;++++++++++++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++++++++++++



;********************
.KeyboardRead
;********************

If RawStatus(#UP) Then PL1_Y-#PLAYER_SPEED    ;W
If RawStatus(#DOWN) Then PL1_Y+#PLAYER_SPEED    ;S
If RawStatus(#LEFT) Then PL1_X-#PLAYER_SPEED    ;A
If RawStatus(#RIGHT) Then PL1_X+#PLAYER_SPEED    ;D

If PL1_X<#ZERO Then   PL1_X=#ZERO    ; player bounds
If PL1_X>#PLAYER_RIGHT_BOUNDARY Then PL1_X=#PLAYER_RIGHT_BOUNDARY
If PL1_Y<#ZERO Then   PL1_Y=#ZERO
If PL1_Y>#PLAYER_BOTTOM_BOUNDARY Then PL1_Y=#PLAYER_BOTTOM_BOUNDARY

If RawStatus(#KEY_2)  ; add one ship
 If enemiesonscreen<#MAXIMUM_BOBS
  a = AddItem (go())
  enemiesonscreen+#ONE
  go()\x=10+Rnd(#PLAYER_BOTTOM_BOUNDARY)
  go()\y=10+Rnd(#PLAYER_BOTTOM_BOUNDARY)
  go()\name = #ONE
  go()\displacement = #ENEMY_SPEED
  go()\direction = #ZERO
 End If
End If

If RawStatus(#KEY_1)   ; delete one ship
 If enemiesonscreen>#ONE
  a=LastItem (go())
  KillItem go()
  enemiesonscreen-#ONE
 End If
End If


Return

;++++++++++++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++++++++++++



;************************
.LevelBuild
;************************

Use BitMap 3
Cls

x = 0 : y = 112
a = 0 : b = 0


Repeat

 Repeat
  Block 23,x,y
  x+16 : a+1
 Until a=18

 x = 0 : y + 16
 a=0 : b+1

Until b=7



Return

;++++++++++++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++++++++++++



;********************
.EndProgram
;********************

AMIGA
NPrint ""
NPrint "Enemies on Screen: " + Str$(enemiesonscreen-1)
End
AlgoRythmic is offline  
 
Page generated in 0.06277 seconds with 11 queries