Create a 2d Shoot'em Up
BlitzMax Forums/BlitzMax Tutorials/Create a 2d Shoot'em Up
Thanks ftbass. Nice idea.
I just had a first look at your code.
That seems nice (I'm just a beginner in Blitz !).
Just two comments:
(1) If I look t this part of code in the Tbonus type (just an example):
If Self.x < 0 - 64 Then
ListeBonus.Remove Self
If Rnd() >= .5 Then
CreateBonus(1024, RndFloat() * 768, "Vitesse")
Else
CreateBonus(1024, RndFloat() * 768, "Tir")
You "hardcode" the size of the sprites (64) and the size of the sceen (1024,768). It's probably better to detect the sizes at the beginning and put them in variables. Your code will be more "independent" from your images/screen size.
(2) just two ideas (maybe not so good, i'm a beginner... ;-) for the collision detection:
- why don't use "collideimage" function (pixel perfect - good examples on this forum) ?
- why don't add the collision detection in each object (type) ? In this case, each "object is responsable to detect the collsion with those wich have an influence on his "life". This can be more "OOP"...
thx for your comments :)
you're right for the 1st point, i'll correct it.
I must be blind because I didn't see the "collideimage" function lol. Now I know it exists. Fine :)
Finally i'll try to add collision detection in each object.
Merci Pit-le-rouge pour ces quelques points à travailler :)
a+
Mais de rien ftbass ;-)
I'm coding a phoenix-clone.
And, as you, I dicovered a lot of tips in the blitz's forums !
Blitz community is really great ! They share a LOT of examples !
A zip version please.
before I forget, thanks :) always nice to find new things for a beginner to learn from :)
I'm really in war with the CollideImage() function :(
I can see that there are collisions, but when there are collisions, CollideImage() returns me a null object...
It would be very nice if someone was able to show me how it works with an example based on the 6th part of my tutorials.
thx, see ya
My first collisions experiment:
Graphics 640,480,0
Type TPlayer
Field X:Int
Field Y:Int
Field img:TImage
Method CheckInput()
X = MouseX()
Y = MouseY()
End Method
Method Draw()
DrawImage(img,X,Y)
End Method
Function Create:TPlayer(X,Y,ImageFile$)
Local p:TPlayer = New TPlayer
p.X = X
p.Y = Y
p.img = LoadImage(ImageFile$,0)
Return p
End Function
End Type
Type TBlock
Field X
Field Y
Field Img:TImage
Function create:TBlock()
Local b:TBlock = New TBlock
b.X = Rand(0,800)
b.Y = Rand(0,600)
b.Img = LoadImage("ball.png")
Return b
End Function
End Type
Global p1:TPlayer = TPlayer.Create(100,100,"test.png")
Global block:TImage = LoadImage("ball.png",0)
Global blockArray:TBlock[50]
For Local i = 0 To 49
blockArray[i] = TBlock.Create()
Next
While Not KeyDown(KEY_ESCAPE)
p1.CheckInput()
p1.Draw()
'DrawImage(Block,200,200)
For Local c = 0 To 49
DrawImage(blockArray[c].img, blockArray[c].X, blockArray[c].Y)
If ImagesCollide(p1.img, p1.X, p1.Y, 0, blockArray[c].img, blockArray[c].X,blockArray[c].Y,0) Then DrawImage(Block, 0,0)
Next
Flip
Cls
Wend
End
thx for helping, but BlitzMax doesn't want to compile :(
"Compile Error
Unable to convert from 'TImage' to 'Int'" (on line 56)
I've just seen the ImagesCollide2() function, simpler for me to use, it should be OK (it is in fact. I've just tried) :)
ps: is it a new function, or am I totally blind O.o ?
ImagesCollide has a slight bug, see this thread for the easy fix:
http://www.blitzbasic.com/Community/posts.php?topic=43386(remember and recompile the modules)
Many thx Perturbatio, I didn't know. Let's try :)
ImagesCollide2 suffers from the same issue.
Waouh... I feel a little bit lost between
ImageCollide()
CollidesImage()
CollidesImage2()...
Anyway, I put my finger on a confusing point (for me) thanks to you :)
thank you very much, see ya
Here has come the 7th part, featuring pixel perfect collisions, sounds, and particles.
I get very inconsistent running speeds; The stars move at a reasonable rate for a period of time then suddenly shoot along for about a second.
Also the ship after a while moved up and down in jumps of about 200-300 pixels.
I'm not very proud of my tweening routine (works fine on my PC, but wanna see how it does on other configurations)... ("just a method, waiting for suggestions" writen in the 1rst post :))
If you take green bonus, the speed of the ship increases without any limit. It will be fixed in the future parts.
Happy to see you tried :)
see ya
Hi
When i compile with 1.03 core it work. But when i use 1.05 i get an error that he miss a file called blitzgldll.a
quite strange... I have no error with the 1.05...
Could anyone else test it, and let us know the issue ?
thx
Ftbass,
I'm on Mac os...
Do you have a mac version of the Part_engine ?
I really want to go through this code, but what language are the variables and comments in ?
Pit, I sent the code of PartEngine to you, so you should see the result. Check your e-mail :)
this code is a BlitzMax tutorial, Deux :)
I mean speaking language :)
I know it is in bmax, hehe
lol... this is french sorry
My english is not really good, but I should have tried to translate...
In the 8th part, I'll try to write comments in english :)
ps: have you tried Google translation tool ?
I will try that, or just guess.
Looks really nice ftbass, I really like it. Just one question, do you have a Macintosh version of PartEngine?
Nicolas.
Sorry, I'm really late :/
I've no Mac version of PartEngine, but you can find it there:
http://www.blitzbasic.com/Community/posts.php?topic=43248or in my personnal web site:
http://ftprods.free.frSo you can build the Mac module, or simpler, use it as an extern library :)
see you
Filax, why don't you edit the original message. Put the links to .zip files in the original message. That may make it more clear that you have .rar and .zip files available.
Thanks for the tutorials. More tutorials are needed for BMax. There is much difference between B3D and BMax.
Edit: I could've sworn the top message had filax as the author. Sorry for that ftbass and filax.
I'm known as ftbass, but you can call me however you want ;)
I edited the first post
regards
What ???
Does someone have a screenshot of this thing running?
Strange O.o
That worked with blitzmax beta, but no more yet :(
I'll take a look to see if I can fix what's going wrong with this thing ;)
see ya
Hi, it does not work, and there is no wai to make it run...
Always the same error: "Identifier TEmitteur not found"... :(((
That's because you need PartEngine (the link is in his first post). You will also have to modify the source so it runs in the newest blitzmax, which shouldnt be too hard (removing bglSetSwapInterval ( 0) and chaging FlushMem to Flip, maybe some more).
Humm... actually I downloaded both the beta5 and beta 6 but it didn't work... I did copy-paste the source code and rebuilt the module after correcting it, I had to add the ":TImage" type declaration after each image variable, and work on each tutorial acting as you suggested, but now it seems to work properly.
Thank you! ;)
Forget it :)
Why take the extra time to type self.x?
Not sure which bit you're referring to but :
Encapsulation?