conversion 2d/3d by Anonymous Coder3rd Feb 2005 13:26
|
---|
Summary you places some sprites, you save your file and you re-examine your save in 3d Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem * Title : Sauvegarde rem savoir c'est qui qui a fait!!! print "Petit-Jean Nicolas" print "Creation de bitmap 3d simplifié" print "Version 1.1 plusieurs formes son prisent en comptes" print "2002" rem sys sync on sync rate 0 cls set display mode 1280,1024,16 rem image load image "mur.bmp",1,1 load image "rond.bmp",2,1 load image "cone.bmp",3,1 load image "cylindre.bmp",4,1 rem etiquette tableau: cls rem nombre d'object() box=1 rem tableau pour object 3d dim 3d(500,4) rem sys hide mouse backdrop on color backdrop 0 rem posy y=0 rem image image=1 rem boucle principal do set cursor 0,0 print "en x ";posx print "en y ";posy print "en z ";posz rem condition pour pouvoir creer le dessin pr trouver le max(voir chargement) if posx>=0 and posy>=0 and posx<50 and posy<50 posx=50 posy=50 endif rem pour les images if inkey$()="1" then image=1 if inkey$()="2" then image=2 if inkey$()="3" then image=3 if inkey$()="4" then image=4 rem pour le mur if mouseclick()=1 or controlkey()=1 sprite box,posx,posy,image scale sprite box,100+posz sleep 100 gosub save box=box+1 else sprite box,posx,posy,image scale sprite box,100+posz endif rem pour posz if inkey$()="+" then posz=posz+5 if inkey$()="-" then posz=posz-5 rem condition if posz<-75 then posz=-75 if posz>200 then posz=200 rem pour enregistrer if inkey$()="s" then gosub enre rem pour un nouveau if inkey$()="n" gosub new sleep 500 goto tableau endif rem position de la souris rem en x a droite if rightkey()=1 posx=posx+36 sleep 100 else endif rem a gauche if leftkey()=1 posx=posx-36 sleep 100 else endif rem en y en bas if upkey()=1 posy=posy-36 sleep 100 else endif rem y en haut if downkey()=1 posy=posy+36 sleep 100 else endif rem ecran sync loop rem sauvegarde de la coord. a chaque new sprite save: 3d(box,1)=posx 3d(box,2)=posy 3d(box,3)=posz 3d(box,4)=image rem pause pour le voir return rem enregistrement du tableau dans un fichier enre: backdrop off rem cache tous les sprites for x=1 to box hide sprite x next x sleep 500 rem ... input "Quelle nom a votre sauvegarde?";nom$ save array nom$+".b3d",3d(1) sleep 500 cls backdrop on rem montre tous les ... for x=1 to box show sprite x next x return rem si on veut faire un nouveau b3d sans recom. le prog. new: for all=1 to 500 if sprite exist(all)=1 then delete sprite all next all sleep 500 undim 3d return Rem * Title : chargement cls rem version 1.1 rem ecran sync on sync rate 0 rem image load image "mur.bmp",1,2 load image "rond.bmp",2,2 load image "cone.bmp",3,2 load image "cylindre.bmp",4,2 rem camera set camera range 1,55000 rem intro print "Chargement de bitmap en 3d" print "Crée par Petit-Jean Nicolas" print "Version 1.1" print "2002" sleep 500 cls rgb(125,125,125) rem etiquette tableau: rem cls rem tableau pour object 3d dim 3d(500,4) rem fichier fichier: rem dossier dir input "Quelle map voulez vous chargé?";nom$ if file exist(nom$+".b3d")=0 print "le fichier n'existe pas" sleep 500 cls goto fichier endif load array nom$+".b3d",3d(1) rem activation d'un ciel(gris) backdrop on color backdrop rgb(125,125,125) rem calcul le nombre de sprites for x=1 to 500 set cursor 0,0 print "nbr de sprites ";x print 3d(x,1) print 3d(x,2) if 3d(x,1)=0 and 3d(x,2)=0 goto partir endif next x partir: cls backdrop on color backdrop rgb(125,125,125) do rem informations set cursor 0,0 print "nbr de sprites ";x print "Conversion--->";x;" Objets 3d" print "Appuyer sur n'importe quelle touche" if inkey$()=""=0 then exit sync loop chargement: rem cache la souris hide mouse rem creation de l'image 2d-->3d for nbr=1 to x if 3d(nbr,4)=1 make object box nbr,36,36,36 texture object nbr,1 position object nbr,3d(nbr,1),3d(nbr,2),3d(nbr,3) endif if 3d(nbr,4)=2 make object sphere nbr,36 texture object nbr,2 position object nbr,3d(nbr,1),3d(nbr,2),3d(nbr,3) endif if 3d(nbr,4)=3 make object cone nbr,36 rotate object nbr,180,0,0 texture object nbr,3 position object nbr,3d(nbr,1),3d(nbr,2),3d(nbr,3) endif if 3d(nbr,4)=4 make object cylinder nbr,36 texture object nbr,4 position object nbr,3d(nbr,1),3d(nbr,2),3d(nbr,3) endif next nbr rem creation de la lumiere for l=1 to 10 make light l position light l,rnd(1000),rnd(1000),rnd(1000) next l color light 1,rgb(0,125,0) color light 2,rgb(0,125,0) color light 3,rgb(0,0,125) color light 4,rgb(0,0,125) color light 5,rgb(125,0,0) color light 6,rgb(125,125,0) color light 7,rgb(125,125,125) rem fog on fog distance 14000 fog color rgb(125,0,0) fog on rem libere la memoire undim 3d() position camera 600,0,1500 pitch camera up 180 rem boucle do rem mouvement camera if upkey()=1 then move camera 10 if downkey()=1 then move camera -10 if rightkey()=1 then turn camera right 5 if leftkey()=1 then turn camera left -5 if inkey$()="$" then pitch camera up 5 if inkey$()="µ" then pitch camera down 5 rem pos cam x=camera position x() y=camera position y() z=camera position z() rem animations if inkey$()="&" for nbr=1 to x-1 roll object right nbr,5 next nbr endif if inkey$()="é" for nbr=1 to x-1 roll object left nbr,5 next nbr endif if inkey$()=""" for nbr=1 to x-1 turn object right nbr,5 next nbr endif if inkey$()="'" for nbr=1 to x-1 turn object left nbr,5 next nbr endif if inkey$()="(" for nbr=1 to x-1 pitch object up nbr,5 next nbr endif if inkey$()="§" for nbr=1 to x-1 pitch object down nbr,5 next nbr endif if inkey$()="è" for nbr=1 to x-1 rotate object nbr,0,0,0 next nbr endif if inkey$()="!" for nbr=1 to x-1 ghost object on nbr next nbr endif if inkey$()="ç" for nbr=1 to x-1 ghost object off nbr next nbr endif if inkey$()="c" gosub fin goto tableau endif text 0,0,str$(x) text 0,30,str$(y) text 0,60,str$(z) position camera x,y,z sync loop fin: backdrop off rem pour charger, il faut vider la mem for v=1 to 500 if object exist(v)=1 then delete object v next v sleep 500 for l=1 to 10 delete light l next x sleep 500 return |