Type Help!
Blitz3D Forums/Blitz3D Beginners Area/Type Help!
| ||
Ok, I'm getting annoyed and confused I've done this AppTitle "BreakIn! (beta)" Local ScreenWidth = 180 Local ScreenHeight = 182 Graphics ScreenWidth,ScreenHeight,32,2 Type WideScreen Field FileName Field X Field Y End Type WideScreen.WideScreen = New WideScreen WideScreen\FileName = LoadImage("WideScreen.bmp") WideScreen\X = 50 WideScreen\Y = 50 WideScreen.WideScreen = New WideScreen WideScreen\FileName = LoadImage("WideScreen.bmp") WideScreen\X = 100 WideScreen\Y = 100 MaskImage WideScreen\FileName,250,250,250 ClsColor 250,250,250 SetBuffer BackBuffer() While Not KeyDown(1) Cls For WideScreen.WideScreen = Each WideScreen DrawImage WideScreen\FileName,WideScreen\X,WideScreen\Y Next Flip Wend End Now It doesn't seem to be making 2 WideScreen's, but instead trying to move the same 1 widescreen, any suggestions? |
| ||
I don't recommend using 'Widescreen' as the pointer to a type of the same name and then using the same var name to iterate through the type instances. Not sure how blitz handles that but may be ok. Have you tried naming the 1st type instance w1.Widescreen and the second w2.widescreen and then iterating using something like this?? for w.widescreen = each widescreen |
| ||
The code already does what it should. It loads two copies of the same image and draws them in slightly different positions. But is this really what you want? Were they supposed to be different images? If not then there is no reason to load two copies. Just load one and draw it in two places. |
| ||
How would I go about loading the same image then drawing it into two differant places using Types. So I can use Collision Detecting on both images. |
| ||
Oh and one last thing, is there any mIRC chat rooms for Blitz Basic Plus? |
| ||
Well, all you would do is load the image into a global handle, then draw the image using it's global handle as many times as you need.Graphics 800,600 SetBuffer BackBuffer() Type img Field x#,y# Field speedx# Field speedy# End Type Global image=CreateImage(32,32) SetBuffer ImageBuffer(image) Rect 0,0,32,32 SetBuffer BackBuffer() While Not KeyHit(1) Cls If KeyHit(2) Then create_new_type() End If update_types() Text 0,0," press 1 to generate new type" Flip Wend Function create_new_type() i.img=New img i\x=Rnd(100,700) i\y=Rnd(100,500) i\speedx=Rnd(0.5,3) i\speedy=Rnd(0.5,3) End Function Function update_types() For i.img= Each img i\x=i\x+i\speedx If i\x>740 Or i\x <50 Then i\speedx=i\speedx*-1 End If i\y=i\y+i\speedy If i\y>540 Or i\y<50 Then i\speedx=i\speedx*-1 End If DrawImage image,i\x,i\y Next End Function |
| ||
OMG, that is so confusing. :( |
| ||
Sorry, the main bit is the function update_types()Function update_types() For i.img= Each img i\x=i\x+i\speedx If i\x>740 Or i\x <50 Then i\speedx=i\speedx*-1 End If i\y=i\y+i\speedy If i\y>540 Or i\y<50 Then i\speedx=i\speedx*-1 End If DrawImage image,i\x,i\y Next End Function [code] If i take out all the movement crap, your left with : [code] Function update_types() For i.img= Each img DrawImage image,i\x,i\y Next End Function so your basically drawing the image called "image" to the screen at the types x and y pos. |
| ||
Ok, need to keep this simple: Firstly create a Type: Type WideScreen Field FileName Field X Field Y End Type Secondy then I want two of the same Type thingy me bob: WideScreen.WideScreen = New WideScreen WideScreen\FileName = LoadImage("WideScreen.bmp") WideScreen\X = 0 WideScreen\Y = 0 WideScreen.WideScreen = New WideScreen WideScreen\FileName = LoadImage("WideScreen.bmp") WideScreen\X = 200 WideScreen\Y = 200 Then I want to display both of the images in differant locations: For WideScreen.WideScreen = Each WideScreen DrawImage WideScreen\FileName,WideScreen\Y,WideScreen\X Next Is that right, sorry Ross your kinda confusing me, I've only just started using Types and in the headache point of getting them to work. But I do appriciate you helping me. :) |
| ||
Yeah, that's right. Tho i'd do something like w.widescreen, to keep it simple and not cinfuse anything. Makes it easier to type as well. :) But, you can just as easily do image=loadimage("WideScreen.bmp") Type WideScreen Field X Field Y End Type secondly WideScreen.WideScreen = New WideScreen WideScreen\X = 0 WideScreen\Y = 0 WideScreen.WideScreen = New WideScreen WideScreen\X = 200 WideScreen\Y = 200 Display both images: For WideScreen.WideScreen = Each WideScreen DrawImage image,WideScreen\Y,WideScreen\X Next |
| ||
Whoohoo, that works. *Does funky monkey dance around Ross* :P |
| ||
*Looks strangely but smiles onwards* ;) |
| ||
Ross, could I get your MSN Messenger e-mail address (so I can keep bugging you with newbie questions!) :p. only joking, but I would like to beable to ask for some advice from time to time, if you don't mind. :D |