Bubble bath effect, fire effect.
Blitz3D Forums/Blitz3D Beginners Area/Bubble bath effect, fire effect.
| ||
Hi, I'm still trying to get fire to work. I have tried switching the sprite to a cone and sphere. The effects are different. The spheres look like bubble bath. The cones are more like fire but still not right. The cones allowed finishing he first level but still slowed to mud/jello movement. What do the code expressions a/piv and a.fire mean (the . and \ are new to me)? Is there a tutorial on this stuff? What does the error message "memory access violation" mean. It comes with the debugger pointing to "render world." I will add code below to show what I am doing in the hope someone will spot my errors. Global flame04=CreateSprite("gameart\base4.bmp"):HideEntity flame04 Global flame02=LoadSprite("gameart\base2.bmp"):HideEntity flame02 ;Global flame02=CreateCone(8,piv):HideEntity flame02 Global flame03=CreateSprite("gameart\base3.bmp"):HideEntity flame03 ;Global flame02=CreateSphere(piv):HideEntity flame02 - - - - - tfire2.fire2=Add_Fire2(0,0,0) - - - se = 10 main loop - - - tfire2.fire2=Add_Fire2(0,-23,300) Update_Fires2() Add_flame2(0,-23,300) Add_Fire2(0,-23,300) - - - Update_Fires2() - - - se = se + 1 If se >= 10 Then HideEntity flame02 ;Erase_Fires2 ;HideEntity tfire2\piv2 ;erase_Flames2 HideEntity Exp1 TranslateEntity tfire2\piv2,0,-50,0 End If - - - - - ;in collision loop - - PositionEntity tfire2\piv2,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) ;PositionEntity Exp1,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) ;ShowEntity Exp1 ShowEntity tfire2\piv2 se = 0 - - - ;subroutines near end of code file - . .stwof2 flame02=LoadSprite("gameart\base2.bmp");:HideEntity flame02 ;flame02=CreateCone(8,piv2):HideEntity flame02 ;Each Flame of the fire Type flame2 Field ent2 Field ang2# Field size2# Field piv2;mine Field alph2# Field dis2# Field dx2#, dy2#, dz2# End Type ;The fire itself Type fire2 Field piv2 ; Direction Field dx2#, dy2#, dz2# End Type ;Add a fire to the scene Function Add_Fire2.fire2(x2#,y2#,z2#,dx2#=0,dy2#=.23,dz2#=0) a2.fire2=New fire2 a2\piv2=CreatePivot() PositionEntity a2\piv2,x2,y2,z2 a2\dx2=dx2:a2\dy2=dy2:a2\dz2=dz2 Return a2 End Function ;Add a flame to the fire Function Add_flame2(x2#,y2#,z2#,size2#=1,dis2#=.016,dx2#=0,dy2#=0.3,dz2#=0) a2.flame2=New flame2 flame02=LoadSprite("gameart\base2.bmp"):HideEntity flame02 ;flame02=CreateCone(8,piv2);:HideEntity flame02 ;a2\ent2=CreateCone(8,piv2);:HideEntity flame02 a2\ent2=CopyEntity(flame02) PositionEntity a2\ent2,x2,y2,z2 a2\alph2=1 a2\size2=size2 a2\dis2=dis2 a2\ang2=Rnd(360) ;ScaleEntity sphere,a2\ent2,a2\size2,a2\size2 ;ScaleEntity a2\ent2,a2\size2,a2\size2,a2\size2 ScaleSprite a2\ent2,a2\size2,a2\size2;,a2\size2 EntityColor a2\ent2,Rnd(100,255),Rnd(0,200),0 a2\dx2=dx2 a2\dy2=dy2 a2\dz2=dz2 End Function ;Update flames Function Update_flames2() For a2.flame2=Each flame2 If a2\alph2>0.01 Then a2\alph2=a2\alph2-a2\dis2 EntityAlpha a2\ent2,a2\alph2 ;RotateEntity a2\ent2,a2\ang2,a2\ang2=a2\ang2+.2,a2\ang2 RotateSprite a2\ent2,a2\ang2 a2\ang2=a2\ang2+.2;,a2\ang2 MoveEntity a2\ent2,a2\dx2,a2\dy2,a2\dz2 ;Movesprite a2\ent2,a2\dx2,a2\dy2,a2\dz2 Else FreeEntity a2\ent2 Delete a2 End If Next End Function ;Erase all flames Function erase_Flames2() For a2.flame2=Each flame2 If a2\ent2<>0 Then FreeEntity a2\ent2 Next Delete Each flame2 End Function ;Update all fires Function Update_Fires2() For a2.fire2=Each fire2 Add_flame2(EntityX(a2\piv2),EntityY(a2\piv2),EntityZ(a2\piv2),Rnd(1,4),.04,a2\dx2,a2\dy2,a2\dz2) Next Update_Flames2() End Function ;Erase all fires Function Erase_Fires2() For a2.fire2=Each fire2 If a2\piv2<>0 Then FreeEntity a2\piv2 Next Delete Each fire2 End Function Return .stwof3 flame03=LoadSprite("gameart\base3.bmp"):HideEntity flame03 ;Each Flame of the fire Type flame3 Field ent3 Field ang3# Field size3# Field piv3;mine Field alph3# Field dis3# Field dx3#, dy3#, dz3# End Type ;The fire itself Type fire3 Field piv3 ; Direction Field dx3#, dy3#, dz3# End Type ;Add a fire to the scene Function Add_Fire3.fire3(x3#,y3#,z3#,dx3#=0,dy3#=.23,dz3#=0) a3.fire3=New fire3 a3\piv3=CreatePivot() PositionEntity a3\piv3,x3,y3,z3 a3\dx3=dx3:a3\dy3=dy3:a3\dz3=dz3 Return a3 End Function ;Add a flame to the fire Function Add_flame3(x3#,y3#,z3#,size3#=1,dis3#=.016,dx3#=0,dy3#=0.3,dz3#=0) a3.flame3=New flame3 flame03=LoadSprite("gameart\base3.bmp") a3\ent3=CopyEntity(flame03) ;a3\ent3=LoadSprite("gameart\base3.bmp") PositionEntity a3\ent3,x3,y3,z3 a3\alph3=1 a3\size3=size3 a3\dis3=dis3 a3\ang3=Rnd(360) ScaleSprite a3\ent3,a3\size3,a3\size3 EntityColor a3\ent3,Rnd(150,255),Rnd(0,100),0 a3\dx3=dx3 a3\dy3=dy3 a3\dz3=dz3 End Function ;Update flames Function Update_flames3() For a3.flame3=Each flame3 If a3\alph3>0.01 Then a3\alph3=a3\alph3-a3\dis3 EntityAlpha a3\ent3,a3\alph3 RotateSprite a3\ent3,a3\ang3 a3\ang3=a3\ang3+.2 MoveEntity a3\ent3,a3\dx3,a3\dy3,a3\dz3 Else FreeEntity a3\ent3 Delete a3 End If Next End Function ;Erase all flames Function erase_Flames3() For a3.flame3=Each flame3 If a3\ent3<>0 Then FreeEntity a3\ent3 Next Delete Each flame3 End Function ;Update all fires Function Update_Fires3() For a3.fire3=Each fire3 Add_flame3(EntityX(a3\piv3),EntityY(a3\piv3),EntityZ(a3\piv3),Rnd(1,4),.04,a3\dx3,a3\dy3,a3\dz3) Next Update_Flames3() End Function ;Erase all fires Function Erase_Fires3() For a3.fire3=Each fire3 If a3\piv3<>0 Then FreeEntity a3\piv3 Next Delete Each fire3 End Function Return .stwof flame04=LoadSprite("gameart\base4.bmp"):HideEntity flame04 ;Each Flame of the fire Type flame Field ent Field piv Field ang# Field size# Field alph# Field dis# Field dx#, dy#, dz# End Type ;The fire itself Type fire Field piv ; Direction Field dx#, dy#, dz# End Type ;Add a fire to the scene Function Add_Fire.fire(x#,y#,z#,dx#=0,dy#=.23,dz#=0) a.fire=New fire a\piv=CreatePivot() PositionEntity a\piv,x,y,z a\dx=dx:a\dy=dy:a\dz=dz Return a End Function ;Add a flame to the fire Function Add_flame(x#,y#,z#,size#=1,dis#=.016,dx#=0,dy#=0.3,dz#=0) a.flame=New flame flame04=LoadSprite("gameart\base4.bmp") a\ent=CopyEntity(flame04) PositionEntity a\ent,x,y,z a\alph=1 a\size=size a\dis=dis a\ang=Rnd(360) ScaleSprite a\ent,a\size,a\size EntityColor a\ent,Rnd(150,255),Rnd(0,100),0 a\dx=dx a\dy=dy a\dz=dz End Function ;Update flames Function Update_flames() For a.flame=Each flame If a\alph>0.01 Then a\alph=a\alph-a\dis EntityAlpha a\ent,a\alph RotateSprite a\ent,a\ang a\ang=a\ang+.2 MoveEntity a\ent,a\dx,a\dy,a\dz Else FreeEntity a\ent Delete a End If Next End Function ;Erase all flames Function erase_Flames() For a.flame=Each flame If a\ent<>0 Then FreeEntity a\ent Next Delete Each flame End Function ;Update all fires Function Update_Fires() For a.fire=Each fire Add_flame(EntityX(a\piv),EntityY(a\piv),EntityZ(a\piv),Rnd(1,4),.04,a\dx,a\dy,a\dz) Next Update_Flames() End Function ;Erase all fires Function Erase_Fires() For a.fire=Each fire If a\piv<>0 Then FreeEntity a\piv Next Delete Each fire End Function Return When the program is run the error message “memory access violation” pops up and the debugger points to render world, the game slows down to mud. Thanks Gerald Nelson |
| ||
User defined types are described in the Language Reference on the Help page the IDE. There are tutorials scattered in various places. I'm sure you can find them. Memory Access Violation is a generic "something went wrong" message from Windows, not from the Blitz debugger. You may not even have Debug enabled. Do that from the Program menu in the IDE. In general you should try to simplify your code, leaving only enough to reproduce the error. Throwing even more code on top of something that doesn't work is not likely to help. It's hard to offer specific advice on code we can't even attempt to run. |
| ||
A mav at renderworld may happen if a surface has more than around 32768 vertices or triangles, (on some graphics cards). |
| ||
Hi, I have gotten to the snow effect stage. The sphere bubbles are at the top of the screen and descend. I got them to position at the camera but not to "parent lock" to the camera. The spheres do not need a pivot like the sprites of the fire program. I cannot get rid of the pivot or lock the snow/entity to the camera movement. How can I lock the snow to the parent camera? Thanks for your input. Gerald Nelson code follows. Global flame04=CreateSprite("gameart\base4.bmp"):HideEntity flame04 ;Global flame02=LoadSprite("gameart\base2.bmp"):HideEntity flame02 ;Global flame02=CreateCone(8,piv):HideEntity flame02 Global flame03=CreateSprite("gameart\base3.bmp"):HideEntity flame03 Global flame02=CreateSphere(piv):HideEntity flame02 - - - - - tfire2.fire2=Add_Fire2(0,0,0) - - - se = 10 main loop - - - tfire2.fire2=Add_Fire2(0,-23,300) Update_Fires2() Add_flame2(0,-23,300) Add_Fire2(0,-23,300) - - - Update_Fires2() - - - se = se + 1 If se >= 10 Then HideEntity flame02 ;Erase_Fires2 ;HideEntity tfire2\piv2 ;erase_Flames2 HideEntity Exp1 TranslateEntity tfire2\piv2,0,-50,0 End If - - - - - ;in collision loop - - PositionEntity tfire2\piv2,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) ;PositionEntity Exp1,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) ;ShowEntity Exp1 ShowEntity tfire2\piv2 se = 0 - - - ;subroutines near end of code file - . .stwof2 .stwof2 ;flame02=LoadSprite("gameart\base2.bmp");:HideEntity flame02 ;flame02=CreateCone(8,piv2):HideEntity flame02 flame02=CreateSphere(8,camera):HideEntity flame02 ;Each Flame of the fire Type flame2 Field ent2 Field ang2# Field size2# Field piv2;mine Field alph2# Field dis2# Field dx2#, dy2#, dz2# End Type ;The fire itself Type fire2 ;Field piv2 Field piv2 ; Direction Field dx2#, dy2#, dz2# End Type ;Add a fire to the scene Function Add_Fire2.fire2(x2#,y2#,z2#,dx2#=1,dy2#=.23,dz2#=1) a2.fire2=New fire2 a2\piv2=CreatePivot() ;a2\piv2=CreatePivot(camera) PositionEntity a2\piv2,x2,y2,z2 a2\dx2=dx2:a2\dy2=dy2:a2\dz2=dz2 Return a2 End Function ;Add a flame to the fire Function Add_flame2(x2#,y2#,z2#,size2#=1,dis2#=.016,dx2#=1,dy2#=0.3,dz2#=1) a2.flame2=New flame2 ;flame02=LoadSprite("gameart\base2.bmp"):HideEntity flame02 ;flame02=CreateCone(8,piv2);:HideEntity flame02 ;a2\ent2=CreateCone(8,piv2);:HideEntity flame02 flame02=CreateSphere(8,camera):HideEntity flame02 a2\ent2=CreateSphere(8,camera):HideEntity flame02 a2\ent2=CopyEntity(flame02) PositionEntity a2\ent2,x2,y2,z2 a2\alph2=1 a2\size2=size2 a2\dis2=dis2 a2\ang2=Rnd(360) ScaleEntity a2\ent2,a2\size2,a2\size2,a2\size2 ;ScaleSprite a2\ent2,a2\size2,a2\size2;,a2\size2 ;EntityColor a2\ent2,Rnd(100,255),Rnd(0,200),0 EntityColor a2\ent2,250,250,250 a2\dx2=dx2 a2\dy2=dy2 a2\dz2=dz2 End Function ;Update flames Function Update_flames2() For a2.flame2=Each flame2 If a2\alph2>0.01 Then a2\alph2=a2\alph2-a2\dis2 EntityAlpha a2\ent2,a2\alph2 RotateEntity a2\ent2,a2\ang2,a2\ang2=a2\ang2+.2,a2\ang2 ;RotateSprite a2\ent2,a2\ang2 ;a2\ang2=a2\ang2+.2;,a2\ang2 MoveEntity a2\ent2,-a2\dx2,-a2\dy2,-a2\dz2 ;Movesprite a2\ent2,a2\dx2,a2\dy2,a2\dz2 Else FreeEntity a2\ent2 Delete a2 End If Next End Function ;Erase all flames Function erase_Flames2() For a2.flame2=Each flame2 If a2\ent2<>0 Then FreeEntity a2\ent2 Next Delete Each flame2 End Function ;Update all fires Function Update_Fires2() For a2.fire2=Each fire2 Add_flame2(EntityX(a2\piv2),EntityY(a2\piv2),EntityZ(a2\piv2),Rnd(1,4),.04,a2\dx2,a2\dy2,a2\dz2) Next Update_Flames2() End Function ;Erase all fires Function Erase_Fires2() For a2.fire2=Each fire2 If a2\piv2<>0 Then FreeEntity a2\piv2 Next Delete Each fire2 End Function Return |