Beginners guide to BlitzMax
BlitzMax Forums/BlitzMax Tutorials/Beginners guide to BlitzMax
| ||
This is what the guide contains (Version 10): ____________________________________________ * The basics of BlitzMax and Programming. * Programmings tips and trick in BlitzMax * It is a quite complete guide to how BMax works * Arrays explained * A lot about Types * How Object Oriented Programming works in BMax * How Lists works * DeltaTime * How Image,Animations and Sound work * Short on Timers * Collision detection If you know the basics of programming in another language I hope this guide will help you to get into the BlitzMax world. This guide is not for those that are totally new to programming in general. Beginners Guide to BlitzMax version 10!(HTML) - Converted by Emmett! Beginners Guide to BlitzMax version 10!(PDF) Download Version 5 (Out of Date!) in français: Beginners Guide to BlitzMax Version 5 - in French - Translation/Decoding BenyBoy Download Version 5 (Out of Date!) in Russian: Beginners Guide to BlitzMax Version 5 - in Russian Please, feel free to post any comments! Regards, Wave~ |
| ||
Fantastic work Wave, this is very useful :) |
| ||
Thanks! Hope you like it =) |
| ||
Great stuff Wave! Any chance of a copy of the original word doc? |
| ||
tnx, np Mailed it to you Rik |
| ||
This is an excellent Guide to blitzmax. Many thanks :) |
| ||
Yep... absolutely fantastic stuff. |
| ||
odd.. don't seem to have received it.. unless it got erroneously marked as spam or something on the server.. sorry to be a pain but could you try again to richard(at)olpin(dot)net Thanks |
| ||
Awesome! I always love any extra help where I can get it! Thanks for the time and effort!! |
| ||
Hi Wave, thank you for this help! Greetings, taumel |
| ||
By the way to the topic Animations: Does there exist a tool or a script to automatically generate the animationpictures out of several singleframes? Greetings, taumel |
| ||
Try glueit... http://turbo.gamedev.net/Glueit06.zip |
| ||
Thanks it worked. Only one thing because i normally use PNGs: Is there also such a tool which supports PNGs instead of BMPs? Greetings, taumel |
| ||
There are a few bmp to gif and gif to bmp but nothing I've found for PNG. I tend to do an Open/Save As conversion to BMP, run glueit then convert the output bmp to png. Not sure how much I lose in quality doing the conversion but my artwork is so bad it wouldn't matter anyway ;) |
| ||
Well problem is that when i render for instance an animation out of max with PNGs everthing is fine. When i do the same wtih BMPs the alpha-channel is lost. Greetings, taumel |
| ||
Oh well. Maybe you can have a look around. It might be a good idea to start another thread so we leave this one dedicated to the Beginners Guide. Good Luck |
| ||
tonyg:PNG provides lossless compression, so the quality is exactly the same as a bmp. |
| ||
So doing... png -> bmp -> png will produce exactly the same quality? Doesn't that mean that bmp would have to have lossless compression as well? |
| ||
png's are compressed, but looses no information upon comression.. (think zip or whatever).. bmp's aren't compressed at all... each pixel is defined with it's colour-value... (or atleast, something along those lines) |
| ||
Oh well. Maybe you can have a look around. It might be a good idea to start another thread so we leave this one dedicated to the Beginners Guide. Good Luck Okay but wouldn't it also be useful for a beginner to know how to produce these graphics, before he/she can use them? Greetings, taumel |
| ||
Okay but wouldn't it also be useful for a beginner to know how to produce these graphics, before he/she can use them? Yes it would but is that really the Beginner's Guide to *BlitzMax*? |
| ||
Thanks for the great response =) Taumel you do have a point which I overlooked, Image editing programs. There is a great program Irfanview which can open any image format and save it/ convert it to any other. And the best thing is that is is Freeware!! I use it for converting .bmp to .ico which works perfect =) You can use it to convert you gif,bmp,tiff,ico,animated cursors.., The downside is that it is only for Windows. I don't use it to draw images or animations. For that I personally use Picture Publisher 8, which I like, but I would guess the most popular is Photoshop. Never tried to do animations in PH so I can't tell if it is any good. If you use 3Dmax can't you simply set the background to black and use the image directly? That's what I did with a explosion animation a long time ago but I pasted each of the 25 gif-frames manually into a large bmp file =) But if you use GlueIT you should get your animations going in no-time. Like said, use any image editor you feel confortable with then convert or put together the images afterwards if you need to. If you convert bmp<->png you shouldn't lose any data except the alpha color, which you may need to repecify (I do that when I create webpages anyway) |
| ||
Yes it would but is that really the Beginner's Guide to *BlitzMax*? Well i'm a beginner to blitzmax and from my point of view it would make sense because: - when i learn about a new thing then i maybe also want to use it and i can't reasonably use this command without such a tool/script. - it's not a big effort when you know how to do it (just make a footnote with the tool-name and maybe a link - that's it) - it much nicer when a tutorial explains the complete chain and doesn't explain a->w but leaves you in the dark with x->z. But of course this is a question of who is the targeted audience for it. Is this a blitzX to blitzMAX tutorial or is it a x to blitzMAX tutorial. Greetings, taumel |
| ||
- it much nicer when a tutorial explains the complete chain and doesn't explain a->w but leaves you in the dark with x->z. I agree with you. But I left it out because I thought almost everyone would use different programs. To test BlitzMax I used Paint, it is fast and easy but it doesn't give the same quality as the more advanced programs. When drawing animations I really only have one tip to give you and that is: Start with Frame one Draw your fire/missile/Tank/Explosion. Then open a copy of that image and alter the image. If you do a couple of frames try running it in game to see how it looks, change the speed of the animation if required. Tell me if there is anything specific you are missing, I would be happy to add it =) // Wave~ |
| ||
Hello Wave, well thanks for your help. I found that naming such a tool is of importance because while i was playing around with blitzMAX i also did an animation with 3dmax and exported it, then i changed a little thing here and exported it, then i changed another little thing there and export it. And under this scenario doing this by hand does not make sense. But don't get me wrong i didn't want you to explain how to use external tools. Just naming one or several of them if available would be great. Greetings, taumel |
| ||
...and don't forget that you can do it by hand using an image editors Grid Snap tool. In addition, do the images have to be side-by-side now? P.S. If you name a freeware tool then it's possible any URL (or the tool) might disappear. Maybe a tool could be written in BlitzMax. Just need to find out how to save a screen... |
| ||
Hello, yesterday i did a little tool for this...jump Greetings, taumel |
| ||
Hi wave, thx for that tutorial, I just begin, and I am a real beginner. One thing to tell you, Page 3 - If-statements The comment to A:+B "That is: B=B+A" should be "That is: A=A+B" best wishes Mipooh |
| ||
Thanks! I will fix that=) |
| ||
Super! 2 tumbs up for this tutorial! ![]() |
| ||
Super job ! |
| ||
Thanks! Glad you like it =) |
| ||
Grate tutorial Wave~ as someone who is about to buy Blitzmax this will really help me, pdf format is alot easyer to follow :), any chance in make a tutorial for differnt types of games, like a simple dungeon crawler/ Fighter Game/ 3D Shooter :) anyways keep up the good work. |
| ||
Thanks, yea I was thinking of expanding it to include some simlpe game types but I don't really have the time :/ |
| ||
Thanks a lot for this great intro to BMAX :) I' ve made a french version of your tutorial which you can get here : http://ben.kicks-ass.net/BlitzMaxGuide.txt cheers ! |
| ||
would be nice to have the updated version assuming that it is improved. in version 5 there is a mistaken array declaration, so it would not be possible to start the program. Local NameList$[]=["Dawn","Trac","Fire","Nitro","Nex"] the "[]=" is missing ... |
| ||
That was fixed along alot of extra stuff.. Almost all chapters was added to and checked with both text and examples. I was waiting for Blitz Research to host it.. but seems like they never will. Anyway now I got my own hosting up so I'll fix the link right away! Hope that fixes it! |
| ||
Keep up the excellent work. I have been wondering about the syntax of BMax and the vocab as well... Are there any B+ like windows component commands? |
| ||
Thanks! Are there any B+ like windows component commands? I think it's in progress. It's planned as far as I know. |
| ||
Man this guide is awesome. You really got the point. Instead of long boring theoric discussion, some simple but realistic code that illustrates the use of the different o-o concepts... Maybe you'll be the one that gets me into o-o :-) |
| ||
Really nice. I can really use BMax now. Great stuff. Keep it up. |
| ||
Thanks! |
| ||
Cheers Wave, a very nice guide |
| ||
yeah, this is what i used to learn bmax !! What about a second installment Wave ? A more advanced one ? |
| ||
Glad to hear =) One on network is coming up but I have no release date yet. What topics do you think I should cover if I make an advanced version? What I can come up with right now: - Simple Maps w/scroll - Particle Effects - Simple Vector Movement/Physics - File handling: save/load highscore and maps - Multiplayer/Network Anything more? Please suggest anything on your mind and I'll see what I make of it =) |
| ||
"- Simple Maps w/scroll - Particle Effects - Simple Vector Movement/Physics - File handling: save/load highscore and maps" YEAH, Wave, won't sound greedy, but all seems very interesting to me! what else can i say? ... PLEASE, PLEASE .... |
| ||
Hi, Can someone help with this test program, I can not get it to run. It seams that two variables Nr and T were not set locally, had to set them globally, is this the problem. Strict Global Number_of_Tanks = 10 Type Tank Field x#,y# Field Dir% Field Armor% = 100 Field Speed# = 0.2 Field Size% = 25 Global TankNumber = 0 End Type Graphics 800,600 Global TankList:TList=CreateList() Global Nr Global T For Nr = 1 To Number_of_Tanks Local NewTank:Tank NewTank = New Tank NewTank.Armor = 150 + Rand(1,5) * 10 NewTank.x = Rand(5,800) NewTank.y = Rand(5,600) NewTank.Dir = Rand(0,360) ListAddLast Tanklist,NewTank Tank.TankNumber :+ 1 Next While Not KeyDown(Key_Escape) For T:Tank=EachIn TankList DrawRect(T.x,T.y,T.Size,T.Size) DrawText"Number_of_Tanks : "+Tank.TankNumber,20,20 T.x:+T.Speed*Cos(T.Dir) T.y:+T.Speed*Sin(T.Dir) Next Flip Cls Wend |
| ||
Change: For T:Tank=EachIn TankList To: For Local T:Tank=EachIn TankList Or use globals: Global Nr 'This is an int Global T:Tank, T can't be an int, need to be a Tank I'll check it out and then update the guide, The error comes because of the use of strict, variable not declared. Thanks for reporting, Wave~ |
| ||
Hi, Wave Program runs fine now. And thanks for the Max guide, something like this should be sold with BlitzMax I' am new to programming and Max is a bit daunting a first. I see that you are also the author of make asteroids in an hour, thanks for all your efforts could you do a piece on collision detection, as I cannot find out how to do this. using your piece on asteroids, I made a space ship battle one ship left one ship right armed with rockets but sadly no collisions not much fun. thanks anyway. |
| ||
New version of the guide is out! 10! Dalaware, It's often about checking when one object (like a missile) is overlapping another object (say Ship). If it does then explode the missile and damage the ship it overlapped. The two most basic ways to do it is by distance or by a rectsoverlap function. Check all missiles against all ships and all other missile by looping them some times. Perhaps the new collision examples help a little? |
| ||
Excellent work! Excellent Update! You have now version 10, and I a lot of work to do. ;) BTW: The headers always show "Version 8" (or 7 an page 2), forgotten to update them? |
| ||
:) |
| ||
Hi wave I miss some chapters in your Index (page 2) like "Variables" "Start with Graphics" or "The coordinate System". On Page 6 /First Line: Graphics 800,80,0 ;) Here a first look on the german version.(11 pages) http://www.blitzcoding.de/bmmax/wave/bmbeta11.pdf cu |
| ||
This is just great work, Wave... I would think this is of good help for the BlitzMax beginner, as well as a nice "lookup" and "tips 'n tricks" document for the more seasoned BlitzMax'er.. I hope you stick with this one, and continue to update it every now and then... :) |
| ||
@LarsG Thanks, the updates is going to be further and further apart the more complete it gets. As long as poeople find (and report ) bugs N errors I'll be happy to fix them. @Abrexxes, Nice work! Impressive. As always if anyone in the german community finds some error/bug tell them to report it here so I can fix it. I fixed the index, thanks. Regards, Wave~ |
| ||
Wave, links are down, just starting out, everyone is raving about your guide. Is this a tempory thing, or could you email guide to me at wizball007(at)aol(dot)com. Thanks in advance |
| ||
Hmm...works 4 me. Firefox 1.0.4 |
| ||
ooops, my bad, had active x control disabled, DOH! |
| ||
Wave - this is great just what I needed. Have been working with DB for a while and things are quite different here (though better of course!). I would love to see some stuff about how to handle vectors and physics in the guide. I am working on a 2D pool game in Bmax at the moment, and I this would come in handy here. (also if anyone has any ideas on how to implement back and side spin I would be forever grateful - I am more than happy to post my code to date if anyone is interested, or if it would help putting together a tutorial - or even some sort of community pool game project). Thanks again Wave! |
| ||
Thanks for the feedback! I've been working some with vectors in my game but I've never manage to implement vectorized momentum - spin by force - or whatever the correct name is =) I haven't finnished my Vector tutorial "introduction to vector physics" but I feel it needs more content. Right now it merly explains what a vector is =) And when it comes to all purpose physics I think a library would be the best first step, compared to an in-depth explination all "behind the scenes" calculations that is required with physics of all kinds. Look here: PhysicsLib When this is done, it is possible I'll write up a introduction to it. Looks very promising and would probably work for a pool game to. I can mail you my vector Lib if you want to use it in your pool game (perhaps you can extend on it? I have it well commented). Also physics and such should perhaps be in a "Game Physics for BMax" Guide instead, non-beginners often looks the other way when it says "Beginner", when they are not ;) Also a comunity project is not a bad idea but expect to do most of the work yourself though it will probably help a lot of new people if you go open source. Ask about spin in the programming forum, you'll probably get a better response there! |
| ||
Thanks Wave. I like to have a look at your vector lib so if you could email it to me that would be great. I'll have a look at the physics lib too and see how i get on. If you are interested there is a good vector tutorial here: Vectors The code in it relates to Dark Basic, but I think the actual explanations are pretty decent. Cheers |
| ||
Good Link, it will help as reference. Hope you find some use for the vector library =) |
| ||
Is there a tutoria on using TList I am having a problem understanding the built in users' guide definition. I been breaking my head trying to figure it out with out any luck. I need some straight forward examples. specialy with the "first" and "last" definitions. I would apreciate it, if somebody points me in the right direction. |
| ||
I added some code for TList stuff here... Lists |
| ||
Jesse, did you refer to the Guide (in this topic)? There is a lot on TLists in the Beginners Guide To Blitzmax. If you have suggestions of improvement on those then I'm open to suggestion. Or did you refer to the Blitzmax documentation only? The first, last, find and sort commands are all addressed in the guide (at least from what I remember). Perhaps you can find there what you are looking for. Open the guide-pdf and search for "First" and "TList". You can also check the name of the chapters. There is one dedicated to TLists. Guide Progress In addition, I was thinking about cutting the Guide in three pieces. It's starting to get a bit fat, which makes it harder for beginners. And the guide is a bit hard for beginners to programming. It's meant as an intro to Blitzmax not Programming in general, tough Blitzmax would be a good start. You pick the “Starting” piece that fits you the best. Then you go on to the actual guide. >> Learn to program in Blitzmax - For those new to game programming in general. A quick starters guide so that beginners can get some graphics going in no time. OR >> Taking the step into MAX - For those converting to Blitzmax from B3D. This part would include specific tips on the differences and how to convert your B3D code to BMax. AND >> Here comes the guide with the OOP stuff and all the “hidden” secrets. Which will be more of an extended manual than a from page 1 to 20 guide. |
| ||
Still great work there Wave.. just a little notice; on page 5 it says <> means “greater or higher than” and is therefore the same as not. it should say something like <> means “lower or higher than” and is therefore the same as not. |
| ||
I agree, will fix that in the next update, Thanks =) |
| ||
Hi Wave. I think maybe you need refresh your tutorial to BlitzMAX 1.12 version. You have planed do this or you have done this? |
| ||
No I haven't. But I will as time permits. Good pointer. About 1.12, the only thing that would change would be the use of Flushmem. Or is there something more? |
| ||
I tried cutting & pasting the code from page 16 into Max 1.16 (the IDE that comes with it) and I get 'Compile Error Identifier 'List' not found. I'm stumped. Any ideas Wave? Or anyone? |
| ||
try editing the main loop to:While Not KeyDown(Key_Escape) For Local Tank:TankType = EachIn TankType.List'Global in this type Tank.Draw() DrawText "Number of Tanks : "+tank.List.Count(), 20, 20 DrawText "Press ESC to exit", 20, 40 Tank.Move() Next Flip;Cls Wend |
| ||
Thankyou Lars. That worked. Is this just an error in the guide or is it due to recent updates in Max? |
| ||
Thanks for this super helpfull guide! And it's very much appreciated. |
| ||
Better: try editing the main loop to:While Not KeyDown(Key_Escape) For Local Tank:TankType = EachIn TankType.List'Global in this type Tank.Draw() Tank.Move() Next DrawText "Number of Tanks : "+tank.List.Count(), 20, 20 DrawText "Press ESC to exit", 20, 40 Flip;Cls Wend |
| ||
Presumably that would be so you are not redrawing the text with every iteration of the for-eachin loop, plus it' easier to read? |
| ||
i didn't notice you added a link to my translation, thanks :) Now i think i should update my version ! |
| ||
Just putting in my 2 cents. This guide really helped me a lot getting started. |
| ||
This is such a great tutorial!! :) |
| ||
It truly is. Thanks Wave! |
| ||
Great Doc Wave! |
| ||
Sorry, but i have hat a divorsment do do (*f*my) This Guide will be in german translation in next Time. (Sorry wave, my email has chanched) It will be in PDF (download) and HTML (online) ((Version10, includet a little ElizaEd tut)) cu PS: Sorry for my english *tata* Ps: A first alpha look here http://www.blitzcoding.de/bmmax/wave/bmbeta11.pdf (dont look aktual changes and spelling) |
| ||
It's cool, when your translated it. (Finde es cool, wen du dies übersetzt.) Looking here (Schau hier): http://www.blitzforum.de/viewtopic.php?t=16793 I don't know it's this from your? (Ich weiss nicht ob dies von dir ist?) I kwow, my english it's ... Das sollte schon alles sagen ;-) |
| ||
hi, nein ist nicht von mir. Ich hatte mal angefangen mit V9 wurde aber dann von V10 überrascht. Nachdem ich von der deutschen Comunnity die Schnauze voll hatte und mich scheiden lassen musste versauerte alles auf meinem Laptop. Fertig sind Seite 1 bis 29, allerdings werde ich die aktuelle Version von Wave nochmal abarbeiten. Es freut mich das es Leute in D gibt die dazu fähig sind komplimente zu machen. Die Fertige Version wird allerdings nur an WAVE gesendet und nicht in deutschen Foren beröffentlicht werden. (Es ist ja nicht so als wüsste ich nicht wer vor mir steht*g*) The german version of this will only be distributed by wave-himself and not in german threads. Wave will have the original(*.doc) ans a pdf/html version, He kann make with this wathever he will. First realease of D will be in (hope) 3 weeks, because i change from office to openoffice (and will see ever changings in original). cu by btw I need someone to check spelling morszeck ;) |
| ||
This is a most valuable tool for learning a poorly documented language. This will occupy a spot on my desktop! |
| ||
Thanks for all the nice comments. Abrexxes, you are of course free to have the translated guide availible for download at your site if you want. Mail me when it is done and I'll put it up on my ftp too. I'll see if I can make some time to update the guide to reflect the latest changes in Blitzmax. |
| ||
Wave, just wanted to say "Good job!". Very helpful. I, too, wrote a user guide, but my skill level is only somewhere between begnner and intermediate. Anyway, I think it's pretty good and here it is if anybody is interested: www.geocities.com/amiga5k/BMG_2.pdf (pdf format) www.geocities.com/amiga5k/BMG_2.xhtml (web format) The original document was created with the excellent (and free) OpenOffice.Org 2.0 'Writer' program (part of the whole suite). If you want it in this format, so you can easily edit it, here it is: www.geocities.com/amiga5k/BMG_2.zip (includes images used as well) Anyone and everyone are welcome to do with these as they wish. You can even put your name on it! (Of course, if you have some scrouples...)... Russell |
| ||
Thanks ! For those like me who don't like acrobat reader there is Foxit reader which is faster and just better : http://www.foxitsoftware.com/ |
| ||
I am going through the example on page 16 and i keep getting an error saying: Identifier List not found. The cursor jumps to the following line. For Local tank:tanktype = EachIn List in the main loop. I have checked multiple times and i can't see any spelling errors. I also don't seem to be able to put the program in debug mode. I see page 43 talks about debugstop and waitkey. i placed them after the graphics command but all i get is the error message. I am used to debugmode in Visual basic 6 but haven't figured it out properly in BlitzMax yet. Any help appreciated Regards Glenn |
| ||
Replace 'eachin list' to 'eachin tanktype.list' Replace 'list.count()' to 'eachin tanktype.list.count()' The list is global to the tanktype so the type needs to be specified when called outside the type. It's an error with the example. <edit> Debugstop only works in Debug mode (Program / Build options/ Debug Build). However, the 'list' occurs at compile time so debugstop doesn't catch it... I think. |
| ||
many thanks |
| ||
Excellent work! Thanks! :) Wave, can you e-mail me the original DOC file? Send to macintoshsauceATgmailDOTcom. Thanks so much! |
| ||
Tutorial - Cool! Thank you, Wave! |
| ||
Here's version 5 translated to Russian by Maniak_Dobrii: http://blitzetc.boolean.name/add/wave.htm |
| ||
I ran into some issues with the array examples on Page 8. I'm running in BlitzMax 1.28. (If you think my example could be written better, please speak up - I'm new at this. ;) ) The big change is in the PrintArray function. The rest is pretty much cosmetic changes for readability. Global Name$[] 'Declare an Array! Print "Start Array Test ----------" Name = ["Torm","Arth","Yire","Float","Stew","Sword","Dew","Flash","Lost","Temore"] PrintArray(Name) Print "---Set this Array to this instead----------------" Name = ["Storm","Earth","Fire","Water","Moon","Sunshine"] PrintArray(Name) Function For LocalS2$ = EachIn Arr If S2 <> "" Print S2$ Next Print "Array Length was : "+Arr.length EndFunction My rework: SuperStrict Global Name:String[] 'Declare an Array! Print "Start Array Test-------" Name = ["Torm", "Arth", "Yire", "Float", "Stew", "Sword", "Dwe", "Flash", "Lost", "Temore"] PrintArray(Name) Print "----Set this Array to this instead----------" Name = ["Storm", "Earth", "Fire", "Water", "Moon", "Sunshine"] PrintArray(Name) Function PrintArray(Arr:String[]) For Local S2$ = EachIn Arr If S2 <> "" Print S2$ Next Print "Array Length was: "+Arr.length EndFunction |
| ||
The big example on Page 11 doesn't work as written - the main issue is that in the "While Not KeyDown(Key_Escape)" loop, the list needs to be identified as TankType.List, not just List. Old version below, followed by mine. Like with the other one, I'm running in SuperStrict. Note: Since I haven't said it otherwise, thanks VERY much to Tibit for doing this tutorial. It's been amazingly educational, and I've only learned more by figuring out where it doesn't currently work. Strict Global Number_of_Tanks = 20 Type TankType 'Renamed from TTank to TankType Field X#,Y# Field Dir, Armor = 100 Field Speed# = 0.2, Size = 25 Global ModelName$ = "Delta 11" Global List:TList 'Keep our tanks inside our TankType Method Draw() DrawRect( X, Y, Size, Size ) End Method Method Move() X:+Speed*Cos( Dir ); Y:+Speed*Sin( Dir ) End Method Function Create() Local NewTank ; TankType NewTank = New TankType NewTank.Armor = Rand( 5 )*10 + 150 NewTank.X = Rand(5, 800 ) ; NewTank.Y = Rand( 5, 600 ) NewTank.Dir = Rand( 0, 360 ) If Not List Then List = CreateList() List.AddLast( NewTank ) EndFunction End Type Graphics 800,600,0 For Local N = 1 To Number_of_Tanks TankType.Create() Next While Not KeyDown(Key_Escape) For Local Tank:TankType = EachIn List 'Global in this type Tank.Draw() DrawText "Number of Tanks : "+List.Count(), 20, 20 DrawText "Press ESC to exit", 20, 40 Tank.Move() Next Flip;Cls Wend My update: SuperStrict Global Number_of_Tanks% = 10 Type TankType Field X#, Y# Field Dir% Field Armor% = 100 Field Speed# = 0.2 Field Size% = 25 Global ModelNames$ = "Delta 11" Global List:TList Method Draw() DrawRect(X, Y, Size, Size) End Method Method Move() X:+ Speed*Cos(Dir) Y:+ Speed*Sin(Dir) End Method Function Create() Local NewTank:TankType = New TankType NewTank.Armor = Rand(5)*10 + 150 NewTank.X = Rand(5, 800) NewTank.Y = Rand(5, 600) NewTank.Dir = Rand(0, 360) If Not List Then List = CreateList() List.AddLast(NewTank) End Function End Type Graphics 800,600,0 For Local N% = 1 To Number_of_Tanks TankType.Create() Next While Not KeyDown(KEY_ESCAPE) For Local Tank:TankType = EachIn TankType.List Tank.Draw() DrawText("Number of Tanks: "+TankType.List.Count(), 20, 20) DrawText("Press ESC to exit.", 20, 40) Tank.Move() Next Flip Cls Wend |
| ||
I'm new to BlitzMax but not to programming, and am about half way through this tutorial (I've just completed the example in the above post). Wonderful job - I like tutorials that explain WHY you're doing things a certain way, and why alternatives might be better or worse. A HUGE thanks for writing this. It's nice to read something that doesn't assume a certain level of knowledge of BMX, yet doesn't spend time laboring over basic points. |
| ||
I've only learned more by figuring out where it doesn't currently work. Thanks :)Cool that you see the "not updated" examples as a feature. And Sharon, you are welcome :) I'm happy the guide is still of use. It does inspire me to write more articles. |
| ||
It does inspire me to write more articles. Please do :) |
| ||
Why doesn't the HTML version indent any of the code? It's very important for beginners to pick up on early. |
| ||
WoW is nmax realy 5 years old? |
| ||
woot its now almost 10 years old. |
| ||
Hey, in part about deltatiming, it can go bonkers in some specific cases, e.g. when you try to make timer that is tied to deltatime, unless you call UpdateDeltaTime() at least once before main program loop. Example of the issue: Global DeltaTime:Float Global TimeDelay:Int ' Millisecs() returns int Function UpdateDeltaTime() DeltaTime = (MilliSecs()- TimeDelay )*0.001'Delta Timer TimeDelay = MilliSecs() EndFunction graphics 640,480,0 timer#=0 Repeat Cls PollEvent If CurrentEvent.id = EVENT_APPTERMINATE Then Exit UpdateDeltaTime() timer#=timer#+DeltaTime 'on the first iteration timer will be in somewhat high values DrawText "Timer: "+timer#,0,0 Flip Forever EndGraphics This simple change to the code solves the issue without having to call UpdateDeltaTime() at least once outside main loop: Global DeltaTime:Float Global TimeDelay:Int= MilliSecs() ' Millisecs() returns int Function UpdateDeltaTime() DeltaTime = (MilliSecs()- TimeDelay )*0.001'Delta Timer TimeDelay = MilliSecs() EndFunction |
| ||
Hey - I wasn't ready to post this yet, that's weird, browser shut down - okay, picking up where I left off then (editing). I'm just going through the help, seeing if there's anything new I can learn. There are a few cosmetic errors, nothing serious. on the RANDOM help you have: Where the opening parenthesis is black against a dark background instead of white as the closing parenthesis is. Page 4, (sp) strict written as scrict Page 4, at the bottom it is stated that Endif can be written as [b]End If, however ElseIf as an option to be written as Else If is not stated. page 6, I am noting that some source code examples do not have all the commands with the first letter uppercase, I.E.: Graphics 800,80,0 but then the commands after it repeat drawrect are lowercase. page 6, the title of the chapter is "Flip and Clear" but there is no clear statement, it is called Cls, while that may be implied, beginners may be confused by this. page 7 is writing several lines of code thus: If KeyDown(Key_Left) X:-1 while technically correct, it is leaving out the Then statement, which is common practice in BASIC. page 7, Local TotalData$ = "Name: " ", ID: "+id+", Age: " +Age compiles as an error, I think there are too many quotes. page 8, cosmetic, Test = Rand 1,3) where the opening parenthesis is black on a dark background instead of white as the closing parenthesis is. page 8, the following statement Local Grid[][] = [ [1,1,1,2],[7,7],[5,5,5] ] would be rather difficult to follow for beginners. A graphic representation done on a grid might assist in this. page 8, the following code is presented: For X = 0 To 2 For Y = 0 To 2 Print Grid[X,Y] Next Next But no tabulation or indentation is given, which is a good practice for any programmer to follow. page 10, in the source code included, two lines are typed as one: DrawText "Press ESC to exit", 20, 40 Tank.Move() Not so sure if it's good programming practice to place LOCAL variables inside a FOR/NEXT loop as that is non-standard with most BASICs. page 11, This time the code didn't become smaller but we did [make] it easier to work with in the future. Word make is missing. page 12, run on commands, all in one line giving error when code is attempted to run: f ammo[ missleslotnr ] <= 0 Print "Can't fire, No Ammo in Slot "+MissleSlotNR Return EndIf Print "Tank "+Name+" fired a "+Missile[ MissleSlotNR ]+" from slot "+MissleSlotNR page 15, black text on dark background in source, should be aqua as above page 18, running the sample code to determine Refreshrate gives an error, [b]'Endif' without matching 'If.' |