Hey people!

BlitzMax Forums/BlitzMax Beginners Area/Hey people!

Yahfree(Posted 2007) [#1]
Hey, just bought blitzmax, i'm liking the look of the IDE, i'm a Blitz3D user, i'd like to get started learning the language, any suggestions? tips? starter assignments, welcomes? for me?


Yahfree(Posted 2007) [#2]
Woah, i'm having problems already ..

Graphics 400,300


While Not KeyHit(1)



Wend
End


Edit:
"BlitzMax now features a set of pre-defined keycode constants with different numerical values to previous Blitzes. See the Key Codes section of the documentation (under Module Reference) for details. In particular, if you use the common "Repeat [... ] Until KeyHit (1)" to detect the Esc key, change it to KeyHit (KEY_ESCAPE). The value 1 now relates to a left mouse button press, so don't wear out your Esc key in confusion and frustration..."


H&K(Posted 2007) [#3]
Download BLide
www.blide.org

Oh and hi.


Yahfree(Posted 2007) [#4]
wow my heads spinning with all this module stuff


tonyg(Posted 2007) [#5]
If you have MaxGUI check
The MaxGUI Beginner Tutorial Series
For Bmax check this
Beginners guide to BlitzMax

and this
Learning 2D Game Programming With BlitzMax

and for extra OOP check this
Learning Object-Oriented Programming in Blitzmax

plus any other of the tutorials which take your fancy.

<EDIT> Oh.. and this Orientation guide for existing Blitz users



Yahfree(Posted 2007) [#6]
why doesnt the close button on the window work? and where did that minimize button go?


tonyg(Posted 2007) [#7]
why doesnt the close button on the window work?

Check AppTerminate command.
and where did that minimize button go?

Search using 'Minimize' for a few other posts asking the same.
You can try Minimize / Maximize buttons
in the Code Archives although it's Windows only.


H&K(Posted 2007) [#8]
Isnt the begginers guide to Bmax 1.12?


tonyg(Posted 2007) [#9]
Possibly as it's dated 2005 but 99.9% of it is still valid unless you think otherwise.


H&K(Posted 2007) [#10]
It probably OK, It would be Auto GC.
Was that before auto Handle was scrapped?

@YahFree,
Start Every program with
"SuperStrict"


Yahfree(Posted 2007) [#11]
whats that do? seems like it would make my life miserible as i'm thinking it means that its very strict and won't compile unless everything is absolutely perfect..


tonyg(Posted 2007) [#12]
Yep, which is better than having it compile and havin to debug it later if you've done something wrong.


Perturbatio(Posted 2007) [#13]
It makes sure you declare all your variables and their types before usage, this results in faster code and less errors.


Yahfree(Posted 2007) [#14]
that makes me happy, pretty much the whole b-max source (not the IDE) is included and much of it is coded in b-max, so it looks like it can get very controling and complicated like c++ ect, but can also remain simple and easy.


H&K(Posted 2007) [#15]
You can dowload the code for the IDE as well if you want to, its open sorce, but as I said before DL BLide


Yahfree(Posted 2007) [#16]
Edit: ahhh it wants me to declare 'local' picky picky...


Yahfree(Posted 2007) [#17]
^


Yahfree(Posted 2007) [#18]
ahaha, i cant find the compile button help! :D (create EXE)


Gabriel(Posted 2007) [#19]
There is no way to *not* create an exe. Every time you "build" or "build and run" an EXE is created/overwritten. Just find the folder you put your source code in, and there will be the EXE.


Anatoly(Posted 2007) [#20]
Lol... I'm a blitz3d user and I felt a strong urge to finally buy blitzmax during the last couple of days, but this thread scared me off :)
I'm afraid I'm gonna end up just like that...


Yahfree(Posted 2007) [#21]
hah, i like it, i suggest going for it, so far i'm liking it, its just completely different, still getting used to it


Perturbatio(Posted 2007) [#22]
Lol... I'm a blitz3d user and I felt a strong urge to finally buy blitzmax during the last couple of days, but this thread scared me off :)


I used to be a b3d user, but I I'd never go back now, BMax is faster, more flexible, and generally gives you a warm fuzzy feeling inside.


Yahfree(Posted 2007) [#23]
its telling me i cant convert this into a object on the ListAddlast line..

Global BrickList:TList = CreateList()
'....
'....
'TBrick type
Type TBrick

	Field HP:Int
	Field x:Int
	Field y:Int
	
	Method Create()
		Local tempx:Int
		HP = 1
		ListAddLast BrickList,TBrick
			For check:TBrick = EachIn BrickList
				tempx = check.x
			Next
		x = tempx + 30
		SetColor Rand(100,255),Rand(100,255),Rand(100,255)
		DrawRect x,y,30,20
		SetColor 255,255,255
	End Method
	
EndType


any ideas? i'm trying to add a type to a list through a method, i thought this was possible?


Gabriel(Posted 2007) [#24]
TBrick is the type, not an instance of the type. In a Method Self is the instance.

Also, you can't have a Create Method. It's pointless. Methods are nothing but functions which work on a type instance, and you don't have an instance when you create. Ergo, there is no way to call a method. It needs to be a function.

Thirdly, you're not actually creating anything at all. You don't New TBrick which is how you get an instance.

Fourthly, there's no point making the bricklist global, it belongs to the TBrick type.

Fifth, people weren't kidding when they said to use Superstrict. It would have pointed out many of the errors for you.

Try something more like this ( untested because you can't call SetColor without calling Graphics and I'm not sure why you're looping through a list and drawing a rectangle only when the brick is created )

SuperStrict

'....
'....
'TBrick type
Type TBrick
	
	Global BrickList:TList=New TList

	Field HP:Int
	Field x:Int
	Field y:Int
	
	Function Create()
                Local Brick:TBrick=New TBrick
		Local tempx:Int
		Brick.HP = 1
		BrickList.AddLast(Brick)
			For Local check:TBrick = EachIn BrickList
				tempx = check.x
			Next
		Brick.x = tempx + 30
		SetColor Rand(100,255),Rand(100,255),Rand(100,255)
		DrawRect Brick.x,Brick.y,30,20
		SetColor 255,255,255
	End Function
	
EndType



Yahfree(Posted 2007) [#25]
well, the create method is for setting up everything, and yes i have super-strict on thats why i'm getting all these errors.

at the moment i'm trying to figure out why the bricks are not spreading out like they should:

i'm liking this easy interaction thing with DLL's, also how did B-max get all the Win32 constants? with B3d you had to set the constants up yourself.

edit: also liking this realtime alpha as you can see above.


H&K(Posted 2007) [#26]
Ok, Something that is going to seem totaly pointless to you at this point. If you Extend TBrick, then you wont want TBricks creation and setup to be in the same function. (Dont ask why, just trust me you dont), so..
SuperStrict

'....
'....
'TBrick type
Type TBrick
	
	Global BrickList:TList=New TList

	Field HP:Int
	Field x:Int
	Field y:Int
	
	Method New()
	
		BrickList.AddLast(Self)
	
	End Method
	
	Method Setup:Tbrick()
	
		Local tempx:Int
		Self.HP = 1
		
			For Local check:TBrick = EachIn BrickList
				tempx = check.x
			Next
	
		Self.x = tempx + 30
		SetColor Rand(100,255),Rand(100,255),Rand(100,255)
		DrawRect Self.x,Self.y,30,20
		SetColor 255,255,255
	
		Return Self
		
	End Method
	
	Function Create:TBrick()
	
		Return New TBrick.Setup()
		
	End Function
	
EndType
Ive moved adding the brick to the lits to the New Method, this is just a style prefferance.
Ive Changed Create() to return the New Brick, this doesnt slow the program down at all. And you are not obliged to allocate it to any thing, but if you ever want to, then its there.
Ive moved all the setup of a new brick to the Method setup.
Why?
Well now if you ever extend Tbrick, you can call TBrick setup, which you wouldnt be able to do if it was in the same function as the New command.

EDit: Sorry did realise you'd posted again, this is directed at your post before last. but after Gabs


Yahfree(Posted 2007) [#27]
wow, blitzmax types are extremely more complex then blitz3d types, but so much more flexible..


Yahfree(Posted 2007) [#28]
can someone show me how to set the app title? it keeps giving me errors... from a simple: AppTitle "Hello"


Gabriel(Posted 2007) [#29]
AppTitle="Hello"



Yahfree(Posted 2007) [#30]
-.-


Yahfree(Posted 2007) [#31]
what does b-max have in terms of rectangular area collision? need somthing like B3D's RectsOverlap()

heres the source up to now..


hmm thinking about coding a fancy moving star BG like the star-pong example in the samples...


Perturbatio(Posted 2007) [#32]
http://www.blitzbasic.com/Community/posts.php?topic=66534


Yahfree(Posted 2007) [#33]
thanks, just what i'm looking for, seems to work ok:


i'll add x-axis directional deflection when i get back (IE if it hits the paddle at a far left spot it will fly off more to the left.)


Yahfree(Posted 2007) [#34]
how do i delete somthing off a list: run the example below and try to hit a brick above another brick, you'll see my problem; it still thinks its alive.




Jesse(Posted 2007) [#35]
check for all caps line:



Yahfree(Posted 2007) [#36]
Ahh, so a TList is a type to keep track of other types, and it has its own methods ect, should i worry about creating to many TBricks? as i'm going to be adding/removing them alot and the TBrick part isnt going to move..


Jesse(Posted 2007) [#37]
No. Add as many as you want. Althoug it might get quite slow if excesive large number of instances are stored in it. The reason is that it has to go through the list to find the one it needs to remove. Do a little research on "tlink" it is more eficient and depending on how you use it, might make your game quite a bit faster. But for a game like that you probably won't notice any difference any way.


Yahfree(Posted 2007) [#38]
cool, i'll look into that, thanks.

Well heres a 'alpha' verison of my first B-max game... (a simple breakout clone)

let me know if you find any bugs, i'm going to bed very tried. i believe theres some bugs with the level stuff ..




Jesse(Posted 2007) [#39]
you don't need to keep track of how many brick you have created because Tlist keep track of how many instances of your bricks are stored. you can access it with BrickList.count()


Yahfree(Posted 2007) [#40]
thanks.

try this one out, i'm having some problems it seems like some bricks i hit give me double points, that means i finish the level faster then i'm suppost to and i get extra bricks laid under the new ones..




Jesse(Posted 2007) [#41]
the collition handleing is not being delt logically. at certain instances you are attempting to remove the same object more than once. by the same token you are increasing your accumulator for tiles removed more than once. I have solved it in my computer but I will only post it if you can't figure it out.


Yahfree(Posted 2007) [#42]
well i'm stumped. so if you can i'd apperciate it :).


Jesse(Posted 2007) [#43]



Yahfree(Posted 2007) [#44]
thanks!

its starting to look like a game(added score, gameover screen, pumping up ball speeds per level ect..):



MGE(Posted 2007) [#45]
All you need to do is add some proper timing so it doesn't play faster or slower depending what your refresh or performance is, and you have the foundations for a decent breakout game. Very cool.


Yahfree(Posted 2007) [#46]
proper timing? explain.


Dreamora(Posted 2007) [#47]
FPS / update time difference dependant update logic


MGE(Posted 2007) [#48]
Check this thread here for a demo that's about as easy as it gets. I'm using that method for a game I'm working on:

http://www.blitzbasic.com/Community/posts.php?topic=71030


Yahfree(Posted 2007) [#49]
hmm, interesting, i'm not sure i get it completely, i think i'll return to that later, i'v switched all the RBG bricks to images, i'm trying to create a break effect, using the brick image itself (when colliding with the ball) this is what i have so far..

(Put these images in the same dir.)
wall1.png

wall2.png




never done any sort of special effect seqence creation before, should i try to make a animated image strip with image 1 being the brick and the rest being animation of it blowing up maybe? or should i go with a different direction all together?


Yahfree(Posted 2007) [#50]
trying to anim image route, giving me errors, what am i doing wrong(testing the animation)



wall1_break.png:



Jesse(Posted 2007) [#51]
animation is a bit tricky. first you need to find a way to display each frame long enough for the player to notice it. But it has to be done with out stopping the game play. it is like when you are able to move the paddle while the ball is in motion.
what you are doing is drawing all of the frames in the back page piling each other with in one cycle(one cycle is when you completed all your calculations and drawings and flip the page). When you flip it, the mess/stack is displayed with in the one cycle making it almost too fast for the eye to perceive. you need to display each frame of animation at least several cycles.
I suggest you create a type for the explosion. create it when a tile is collided. and delete it when the animation is completed. if you think you are going to have more than one explosion at a time, create a list to store them and work it like you work the tile list. you can create a counter with in the explosion type that would decrease every cycle and when it reaches 0 display the next frame. and then reasign the counter repeat that until all of the frames are displayed. then delete it. I can easily create one for you but I think you should give it a try first. I will be here if you need some help.
lear how to use "loadanimimage"
this is an example of how it works using your image
Strict
Graphics 800,600
Local image:timage = LoadAnimImage("wall1_break.png",100,50,0,6)
If image = Null Notify "animation not found"
Local counter:Int =20
Local index:Int = 0
SetClsColor(100,100,0)
Repeat 
	Cls
	counter = (counter +1) Mod 10
	If Not counter index = (index+1) Mod 6
	DrawText "Press (esc) to exit",100,0

	DrawImage(image,100,100,index)
	Flip()
Until KeyDown(key_escape)

I don't know if your image is really a png I think is a bmp.


Yahfree(Posted 2007) [#52]
its a png... your example doesnt work? is that intentional?


Jesse(Posted 2007) [#53]
it works I tried it before posting it
make shure you save it first where you have the image saved.
<edit>
I said that because when I tried to save it to my computer it said it was a bmp. I had to convert it back to png after copying to my harddrive.


Yahfree(Posted 2007) [#54]
EDIT: Nevermind, spell mistake on the image directory.


Yahfree(Posted 2007) [#55]
any ideas why this is not working correctly? am i on the right track?




Yahfree(Posted 2007) [#56]
ahh i saw how the old one didnt work, but why doesnt this new one work? it looks good as far as logic..

same images above (wall1.png,wall2.png,wall1-break.png)




Jesse(Posted 2007) [#57]
did you rename wall1_break.png?
anyway here it is rename that file if you need to.



Yahfree(Posted 2007) [#58]
wow.... that looks awsome... thanks, i should be finished with it soon.


Yahfree(Posted 2007) [#59]
Alright its finished, i don't plan to make it very great, just made some photoshop images, added some more gameplay, dressed it up, made a main menu, so now its done.

thanks for all the help, i think i have a basic understanding on how max works vs. b3d..

now i'm gonna try to make a platformer...


Yahfree(Posted 2007) [#60]
reading this again, some mentioned its possible to reduce the creation process:
Global player:TPlayer
.
.
.
.
.
.
	Method Create:TPlayer()
		Local t:TPlayer = New TPlayer
		
		Return t
	End Method
.
.
.
.
player.Create()



is this sort of thing possible? i'm having a horrible time trying to get it working, should i stop and go back to my 1 line more creation process or is this possible? and should i use it vs the other way for good practice or ?


tonyg(Posted 2007) [#61]
It needs to be a function. Methods work on instances of objects.


H&K(Posted 2007) [#62]
It was me,
Type aType
Global List:Tlist= New TList
Method New()
      BrickList.AddLast(Self)
End Method
Function Create:aType() 
     Return New AType.Allocate()
End Function
Method Allocate:aType()
     allocate stuff
End Method
End Type
The reason becomes clear when you come to extend this type, because then you have access to The super.allocation (I called it setup last time
I stopped posting advice, because it became clear that you were going to treat Bmax Types as slightly better b3d types, and not as contained objects.
That is, things like this
For i=1 To NUMBER_OF_BRICKS
	Brick:TBrick = New TBrick
	ListAddLast BrickList,Brick
	Brick.Create()
Next
would not have been in open/main code, and listadd would be inside TBrick.new() and Create would contaied the new. And the Draw commands would have been in AType.Draw etc.

So I felt it better to not post, because it was just a matter of opinion, and
1) Your stuff was working
2) When you ignored it the first time, I felt that you probably didnt really understand why I was saying it, and I know I couldnt expain it any better


Yahfree(Posted 2007) [#63]
yea, i really don't understand it much better then a b3d type, OOP is new to me.. i'll look into it.


Czar Flavius(Posted 2007) [#64]
Global player:TPlayer
.
.
.
.
.
.
	Function Create:TPlayer()
		Local t:TPlayer = New TPlayer
		
		Return t
	End Method
.
.
.
.
player = TPlayer.Create()


Try this.