Help with Lists/methods

BlitzMax Forums/BlitzMax Beginners Area/Help with Lists/methods

Paul "Taiphoz"(Posted 2005) [#1]
hi. trying to code my first we thing in max.

What I am trying to do is just see how the inherits work.
What I have bellow is a type called SpaceObject, this has the common fields of x,y,velocity which are common to all space objects.

I then have a Star type which inherist SpaceObject.
The star type has afew thing for itself like Draw() count and Create.

But I seem to be having trouble either getting it to create and add to the list or drawing the star image to the screen.

I duno about the rest of you but I am finding it hard to do any sort of Debugin (Win32) .. I hope thats something thats going to get worked on.

Any help is welcome and thanks in advance.
'
'
'	My First Blitz Max Prog!.
'
'		Aim : To create some types with its own methods and functions.
'		Aim : To use the new linked list system and understand it.
'
'
'
'
'

Strict

Global GFX_Width		:	Int		=	800
Global GFX_Height		:	Int		=	600
Graphics GFX_Width,GFX_Height,0




Incbin "star.bmp"
Global StarImage		=	LoadImage("incbin::star.bmp")







Global SpaceObjectList:Tlist = CreateList()

Type SpaceObject

	Field pos_x		:	Int
	Field pos_y		:	Int
	Field Velocity	:	Int
	
	Method count:Int()
		Local ret:Int
		ret=0
		For stars = EachIn SpaceObjectList
			ret:+1
		Next
		Return ret
	End Method
	
End Type

Global SpaceObjects:SpaceObject






Type Star	Extends SpaceObject
	
	Function Create:star()
		Local Stars:star = New Star
			'Stars.pos_x=Rand(1,800)
			'Stars.pos_y=Rand(1,600)
			'Stars.Velocity=0
			SpaceObjectList.addlast Stars	
			Return Stars
	End function
	
	Method Draw()
		DrawImage StarImage,100,100
	End method
	
	
	Method count:Int()
		Local ret:int
		ret=0
		For stars = EachIn spaceobjectlist
			ret:+1
		next
		Return ret
	End method
End Type
Global Stars:star


While Not KeyHit(KEY_ESCAPE)
	Cls

		If KeyHit(KEY_SPACE)
			Stars.create()
		End If
	
	FlushMem;Flip
wend



Paul "Taiphoz"(Posted 2005) [#2]
note that the draw,100,100 was a test cos pos_x and y were not working.


Warren(Posted 2005) [#3]
Well, unless I'm missing something obvious, you're not even calling the draw function. You're doing a "flip" but that's about it...

And BTW, "CountList" would be a nice replacement for your "count" functions...


Paul "Taiphoz"(Posted 2005) [#4]
Your right im not, but I was, I didnt realise that I had CTRL+C-ed the one with that line missing so thats not the issue.


Paul "Taiphoz"(Posted 2005) [#5]
I worked it out.

I HAD NO IDEA - that if you wana draw a BMP that you have to import the brl.bmploader

WTF.

Is there anyway to just have all the basics in by default ? like bmp,jpg,png,wav,ogg,avi etc ?? or do I have to find out what all the BRL modules are and import them all at the start of my code ????


Warren(Posted 2005) [#6]
That's a new one on me. Maybe the Windows version is different somehow, but I've never had to explicitly include a module on the Mac...


FoRcE(Posted 2005) [#7]
Well loading a .bmp works fine for me (Win32 version) without having to import anything.

The docs say you only need to import anything manually if you use the Framework command otherwise every mod is imported automatically.


Yan(Posted 2005) [#8]
AFAIK, unless you use the FrameWork command, every module is imported automatically.

[Edit]Beaten to it :o)[/Edit]


Paul "Taiphoz"(Posted 2005) [#9]
Its strange, after I read your post I thought I would comment out the include and now its working without it.

What the heck is going on.

is it possible that for some reason the first time round it just wasnt including the files automaticly.

but after I did it manual it works ?

Its weired.....


Hotcakes(Posted 2005) [#10]
I wouldn't think so ;] But it is beta software. You've never accidentally typed 'Framework' anywhere before? <grin>