read array

Blitz3D Forums/Blitz3D Programming/read array

HI all...

OK I am a little cornfused!

I created an array called ova(80,30)
I filled it with 0's to make sure all was filled

Thirty times I randomly created a location and filled that location in the array with 1's

Now I want to read the array and place an image on the screen where the 1's are.

How do I read the array. The DIM statement text is no help. In Qbasic I think I used to just READ ova(x,y) but the READ commands here do not mention arrays.

; Game 1

Graphics3D 800,600,16,1			; set screen size
SetBuffer BackBuffer()
SeedRnd(MilliSecs()) + Pi

AppTitle "BlowOFF - The game for the rest of us!","Do you Quit?"

; All Bullet Stuff from Ross including timer...
Global main_bullet=LoadMesh("sperm1.b3d"); create a bullet that the type objects can copy.

ScaleEntity main_bullet,1.5,1.5,1.5
HideEntity main_bullet

Type bullet
	Field entity
	Field speed#
	Field range
	Field pivot
End Type

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CREATE ARRAY to hold egg position and fill with 0 for now
Dim ova(80,30)
For ov=0 To 80
For ovo= 0 To 30
ova(ov,ovo) = 0 
Next
Next

camera=CreateCamera()			; create something to see with
PositionEntity camera,0,10,-15


light=CreateLight()				; I will dispense with the biblical reference
RotateEntity light,45,0,0		; move the light a bit to create shadows on the model
AmbientLight 32,32,32


Global turret=LoadAnimMesh("penis1.b3d")
PositionEntity turret,0,0,0


egg1=LoadImage("egg1.png")
egg2=LoadImage("egg2.png")
bip=LoadSound("bip.ogg")

MoveMouse 400,300

;HidePointer

Global gun_timer=MilliSecs() ; timer to track the difference in millisecs
Global gun_time=250; time in milliseconds that the gun will fire

; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= load some eggs into the array
For eggz = 1 To 30
xova=Rand(79)
yova=Rand(29)
ova(xova,yova)=1
Next

While Not KeyHit(1)

For ov=0 To 80
For ovo= 0 To 30
; +++++++++++++++++ HERE IS WHERE I WOULD READ THE ARRAY AND PUT THE IMAGE!!!
next
next

Next

If MouseX()>490 Then MoveMouse 490,MouseY()
If MouseX()<310 Then MoveMouse 310,MouseY()

xx=MouseXSpeed()
yy=MouseYSpeed()

TurnEntity turret,0,xx,0 	; rotate th turret
TurnEntity turret,yy,0,0		; angle the gun


	If MouseDown(1) And MilliSecs()>gun_time+gun_timer Then
	Animate turret,3
		gun_timer=MilliSecs() ; reset the timer
		create_bullet(turret); call function to create a bullet. Pass across the gun entity to the function
						  ; so the bullet can come from the guns position
		PlaySound(bip)
	End If
	
	update_bullet()



UpdateWorld
RenderWorld

;Text 0,10,"X: "+MouseX()
;Text 0,20,"Y: "+MouseY()
;Text 0,40,"Pitch:"+EntityPitch(turret)
;Text 0,50,"Yaw: "+EntityYaw(turret)
;Text 0,70,"MX: "+xx
;Text 0,80,"MY: "+yy


Flip
Wend
End

Function create_bullet(turret_entity)
	b.bullet=New bullet
	
		temp_x=EntityX(turret_entity,True)
		temp_y=EntityY(turret_entity,True)
		temp_z=EntityZ(turret_entity,True)
		
		b\entity=CopyEntity(main_bullet) ; copy the main bullet entity , into the type object
		b\pivot=CreatePivot()
		
		PositionEntity b\entity,temp_x,temp_y,temp_z
		RotateEntity b\entity,EntityPitch(turret_entity,True),EntityYaw(turret_entity,True),0
		PositionEntity b\pivot,temp_x,temp_y,temp_z
		
		b\range=120 ; the range of the bullets
		b\speed=1 ; the speed of the bullets
End Function

Function update_bullet()
	For b.bullet = Each bullet
		MoveEntity b\entity,0,0,b\speed
			If EntityDistance#(b\entity,b\pivot) > b\range Then
			FreeEntity b\entity
			FreeEntity b\pivot
			Delete b.bullet
		End If
	Next
End Function
What am I dong wrong?
-RZ

You just reference it. Eg:

If ova(x,y)=1 then DrawImage image,x,y


or whatever.

By the way, just flicking through your code, I can see that you're not always going to place exactly thirty 1's in the array of zeroes. You're not checking to see if there is already a one in the slot before making it one. In some cases, you will store a 1 there, then come back and make it one again, and you'll have only 29 on screen.

Hi Folks,

Is this game really about what I think it is?

Later,

Jes

Nope... just preoccupied with getting the wife in the family way...

10 sin
20 there is no hell... it is a lie fostered on the people to force them to be religous
30 live free and DON'T tell other people how to live!

-RZ