Need help adding 1 block.
Blitz3D Forums/Blitz3D Programming/Need help adding 1 block.
| ||
Hi all. As most of u probably know, im designing a character creator. Now.. the problem im having is I want to be able to add 1 block or 2 blocks or 3 blocks depending on what i choose. the prob is. i can only add 2 blocks at a time.. I need the blocks to be in this format: X X X and X X X X X and so on ... Dim playermesh(2) playermesh(0) = LoadAnimMesh("media\ninja.b3d") playermesh(1) = LoadAnimMesh("markio\mariorun.x") playermesh(2) = CreateCube() Dim playertype$(2) playertype$(0) = "Ninja" playertype$(1) = "Markio" playertype$(2) = "Cube" While Not KeyHit(1) mx = MouseX() my = MouseY() old_mouse_x = cur_mouse_x ;this is the line where i define the old variable for mousex() cur_mouse_x = MouseX() Shr 1 ;this is the new mousex() mouse_x_delta = cur_mouse_x-old_mouse_x ;this is the current mousex() ;this is what im going to use in the y value of "turnentity player1" characreate = newchar ;this is the old characreate newchar = 0 ;this is the new characreate newfinal = newchar ;this is the value i will use to change characreate to 0 only if you are not mousing over a block. oldselect = newselect newselect = 0 newsfinal = newselect mh = MouseHit(1) omousedown = newmouse_down newmouse_down = MouseDown(1) fmousedown = newmouse_down If player1 <> 0 If fmousedown And mayturn = 0 If mx > ImageWidth(background) TurnEntity player1, 0, mouse_x_delta, 0 Else If mx < ImageWidth(background) Or mx > GraphicsWidth()-1 RotateEntity player1, 0, -180, 0 EndIf EndIf EndIf which=y*2+x If Not mayturn Then fmousedown = 0 If (which <> 0) And mayturn = 1 Then mayturn = 0 If mx < 0 Then mx = 0 If my < 0 Then my = 0 If mx > GraphicsWidth() Then mx = GraphicsWidth() If my > GraphicsHeight() Then my = GraphicsHeight() UpdateWorld RenderWorld tween# DrawImage background, origx#+pos_x#, origy#+pos_y# If mh For x = 0 To 1 For y = 0 To maxblocks imx = (0.2 * width) + (0.57 * width * x) + (origx#) + (pos_x#) imy = (0.2 * height) + (0.1 * height * y) + (origy#) + (pos_x#) If ImageRectOverlap(im, imx,imy,mx,my,1,1) Or (KeyDown(203)-KeyDown(205))*1 which = y * 2 + x selected = which If which <> oldwhich Then HideEntity player1 ShowEntity playermesh(which) player1 = playermesh(which) If which = 0 PositionEntity player1,1,0,8 If which = 1 PositionEntity player1,1,0,8 If which = 0 Animate player1,1 If which = 1 Animate player1,1 If which = 0 Then ScaleEntity player1, .5,.5,.5 : RotateEntity player1, 0, -180, 0 If which = 1 Then ScaleEntity player1, .2,.2,.2 : RotateEntity player1, 0, -180, 0 oldwhich = which Else If which = oldwhich showbox = 1 EndIf EndIf Next Next EndIf For x = 0 To 1 For y = 0 To maxblocks which=y*2+x imx = (0.2 * width) + (0.57 * width * x) + (origx#) + (pos_x#) imy = (0.2 * height) + (0.1 * height * y) + (origy#) + (pos_y#) DrawImage imbg, imx-ImageWidth(imbg) Shr 1, imy-ImageHeight(imbg) Shr 1 DrawImage im, imx, imy, which Next Next For x = 0 To 1 For y = 0 To maxblocks imx = (0.2 * width) + (0.57 * width * x) + (origx#) + (pos_x#) imy = (0.2 * height) + (0.1 * height * y) + (origy#) + (pos_y#) which=y*2+x If (which = selected) Or ImageRectOverlap(im, imx,imy, mx,my,1,1) Or (KeyDown(203)-KeyDown(205))*1 characreate = 1 Color 150,150,150 Rect imx-ImageWidth(im) Shr 1, imy-ImageHeight(im) Shr 1, ImageWidth(im), ImageHeight(im), 0 Rect imx-ImageWidth(im) Shr 1+1, imy-ImageHeight(im) Shr 1+1, ImageWidth(im), ImageHeight(im), 0 If which = 0 Color 0,0,0 Text imx-StringWidth(playertype$(0)) Shr 1-1, imy-StringHeight(playertype$(0)) Shr 2-1, playertype$(0) Color 102,102,255 Text imx-StringWidth(playertype$(0)) Shr 1, imy-StringHeight(playertype$(0)) Shr 2, playertype$(0) Else If which = 1 Color 0,0,0 Text imx-StringWidth(playertype$(1)) Shr 1-1, imy-StringHeight(playertype$(1)) Shr 2-1, playertype$(1) Color 68,207,255 Text imx-StringWidth(playertype$(1)) Shr 1, imy-StringHeight(playertype$(1)) Shr 2, playertype$(1) EndIf EndIf Next Next DrawImage mouseicon, mx, my Flip Wend is it a matter of changing which=y*2+x to which=y*1+x or what? thanks! ~DS~ |
| ||
if u cant read, i can tab this data ~DS~ |
| ||
I can read it... If I look long enough... But what exactly is the problem you're having?? When you say "block," are you talking about cube primitives? |
| ||
I think he means the "im" 2D image, mostly desribed here:For x = 0 To 1 For y = 0 To maxblocks which=y*2+x imx = (0.2 * width) + (0.57 * width * x) + (origx#) + (pos_x#) imy = (0.2 * height) + (0.1 * height * y) + (origy#) + (pos_y#) DrawImage imbg, imx-ImageWidth(imbg) Shr 1, imy-ImageHeight(imbg) Shr 1 DrawImage im, imx, imy, which Next Next For x = 0 To 1 For y = 0 To maxblocks imx = (0.2 * width) + (0.57 * width * x) + (origx#) + (pos_x#) imy = (0.2 * height) + (0.1 * height * y) + (origy#) + (pos_y#) which=y*2+x If (which = selected) Or ImageRectOverlap(im, imx,imy, mx,my,1,1) Or (KeyDown(203)-KeyDown(205))*1 characreate = 1 Color 150,150,150 Rect imx-ImageWidth(im) Shr 1, imy-ImageHeight(im) Shr 1, ImageWidth(im), ImageHeight(im), 0 Rect imx-ImageWidth(im) Shr 1+1, imy-ImageHeight(im) Shr 1+1, ImageWidth(im), ImageHeight(im), 0 |
| ||
May I suggest maintaining a single thread for problems concerning this program? It is much more efficient. |
| ||
yes. i mean the im image. no, not cube primatives. by block, i again mean drawimage im.. yes i will change the thread if i have any more questions. |
| ||
i hope i explained well enough this time |
| ||
What happens if you use more than two blocks? |
| ||
if i change it from 0 to 1 maxblocks which of course u know is 0 = 2 blocks, 1 = 4, and so on.. it simply goes to 4. not 3. i need to be able to change it to whatever amount maxblocks = x x = # i choose to add blocks x = 3, 4, 5.. w/e. and it WILL be 3, 4, OR 5. :) ~DS~ |
| ||
i still need to keep them in rows. HOWEVER. I need the images to be like this: X OR X X OR X X X OR X X X X X and so on :) ~DS~ |
| ||
i hope u understand what i need. if not, i can rewrite the question |
| ||
Ah, I understand. After calculating "which", use a line like this to exit the loop: If which > maxblocks then Exit "Exit" will make the program jump to the next Next .. :S .. I mean it will exit (=break) the loop. You'd have to do that for every For loop that uses these blocks. |
| ||
that did it! thanks again, warner! :) |