FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» bouton dans autre form que 0
Labyrinth - Page 2 Emptypar leclode Aujourd'hui à 13:59

» KGF_dll - nouvelles versions
Labyrinth - Page 2 Emptypar Klaus Aujourd'hui à 11:41

» Gestion d'un système client-serveur.
Labyrinth - Page 2 Emptypar Klaus Aujourd'hui à 10:23

» PANORAMIC V 1
Labyrinth - Page 2 Emptypar papydall Sam 4 Mai 2024 - 3:43

» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
Labyrinth - Page 2 Emptypar Froggy One Jeu 2 Mai 2024 - 11:16

» @Jack
Labyrinth - Page 2 Emptypar Jack Mar 30 Avr 2024 - 20:40

» trop de fichiers en cours
Labyrinth - Page 2 Emptypar papydall Lun 29 Avr 2024 - 23:39

» Une calculatrice en une ligne de programme
Labyrinth - Page 2 Emptypar jean_debord Dim 28 Avr 2024 - 8:47

» Form(résolu)
Labyrinth - Page 2 Emptypar leclode Sam 27 Avr 2024 - 17:59

» Bataille navale SM
Labyrinth - Page 2 Emptypar jjn4 Ven 26 Avr 2024 - 17:39

» Les maths du crocodile
Labyrinth - Page 2 Emptypar jean_debord Jeu 25 Avr 2024 - 10:37

» Naissance de Crocodile Basic
Labyrinth - Page 2 Emptypar jean_debord Jeu 25 Avr 2024 - 8:45

» Dessine-moi une galaxie
Labyrinth - Page 2 Emptypar jjn4 Lun 22 Avr 2024 - 13:47

» Erreur END_SUB
Labyrinth - Page 2 Emptypar jjn4 Lun 22 Avr 2024 - 13:43

» Bug sur DIM_LOCAL ?
Labyrinth - Page 2 Emptypar papydall Dim 21 Avr 2024 - 23:30

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Mai 2024
LunMarMerJeuVenSamDim
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendrierCalendrier
Le Deal du moment :
Jeux, jouets et Lego : le deuxième à ...
Voir le deal

 

 Labyrinth

Aller en bas 
+4
bignono
jpcr
Jicehel
Nardo26
8 participants
Aller à la page : Précédent  1, 2, 3, 4  Suivant
AuteurMessage
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyVen 18 Nov 2011 - 13:15

Bonjour Jicehel
Pour ceux qui n'aurait pas compris comment sont générées les murs du labyrinthe dans les procédures pan1 à pan8:
Après génération du labyrinthe, chaque case a une valeur entre 0 et 14 { a(i,j) } ce qui correspond à:
0 pas de mur
1 mur de gauche
2 mur du bas
3 mur de gauche et mur du bas (1+2)
4 mur de droite
5 mur de gauche et mur de droite (1+4)
6 mur du bas et mur de droite (2+4)
7 mur de gauche, mur du bas et mur de droite (1+2+4) --> cul de sac
8 mur du haut
9 mur de gauche et mur du haut (1+8 )
10 mur du bas et mur du haut (2+8 )
11 mur de gauche, mur du bas et mur du haut (1+2+8 ) --> cul de sac
12 mur de droite et mur du haut (4+8 )
13 mur de gauche, mur de droite et mur du haut (1+4+8 ) --> cul de sac
14 mur du bas, mur de droite et mur du haut (2+4+8 ) --> cul de sac

Amuse toi à dessiner un carré et met les valeurs 1 sur le coté gauche, 2 sur le coté du bas, 4 sur le coté droit et 8 sur le coté du haut.
ça doit faire tilt! Simple, non?

En fin de compte, au début de la génération du labyrinthe, toutes les cases a(i,j) sont mises à la valeur 15 --> (1+2+4+8 ), et ensuite aléatoirement on ouvre une porte ou deux portes ou tois ou quatre. Bien entendu, lorsqu'on ouvre une porte, il faut regarder la case contigüe au mur qu'on enlève et lui enlever le mur correspondant.

L'avantage, c'est qu'à chaque génération on obtient un labyrinthe différent.
Tu peux générer des labyrinthes et mettre les valeurs a(i,j) dans un fichier level.dat pour faire des niveaux différents, mais je n'en vois pas l'intérêt, puisque mon programme est fait pour être intégré dans un plus gros et à générer de manière autonome autant de niveau qu'on veut sans passer par des fichiers extérieurs.

A bientôt
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyVen 18 Nov 2011 - 14:02

En fait, j'imagine l'usage pour un jeu avec des niveau prédéfini
=> Plusieurs niveau se succèdent.
=> On utilise ton principe pour générer des labyrinthe alétoires.
=> On simplifie un peu (le but étant de cheminer mais pas uniquement de trouver la sortie)
=> On met des textures pour faire beau (c'est là que l'on a besoin d'avoir une cohérence, sinon ,il faudrait intégrer des mécanismes de cohérence ou de générateur de salles et là ça sort du but de ton programme initial. J'avoue que mon usage est un détournement du tient pour mon usage personnel Smile )

Sinon pour le case, j'avais fini par comprendre, mais j'avoue que j'ai dû réfléchir au départ pour comprendre, d'où la demande d'ajout de commentaires pour faciliter la lecture du source ^^), mais bon, si j'ai un peu de temps ce week-end, je peux le faire aussi .... Smile

En fait mon usage perso serait de faire un level01.dat, puis un level02.dat, ... en tout cas dans un premier temps.

Mais pour faire simple, dans un premier temps, juste de sortir la génération du labyrinthe pour permettre de modifier le niveau généré, supprimer et modifier quelques murs pour simuler des "salles" et appliquer des textures aux murs.

En fait mes fichier de niveaux ne sont interessant que pour l'usage que j'en ait dans la tête et sans doute pas pour ton idée initiale de génération de labyrinthe automatique, mais elle permet d'avoir en quelques secondes une base sur laquelle travailler. Ton post et ton travail juste à point nommé par rapport au projet de jeux dont je me suis retiré faute de temps mais qui aurait pû faire de très beaux donjons.

Il est possible d'avoir des donjons totallement aléatoires, mais cela dépasse mes petites compétences, à mon niveau, je préfère scripter et controler, maintenant, si cela t'interesse, tu peux te baser sur ton programme pour faire un "générateur aléatoire de donjons" basé sur un labyrinthe et des salles particulières "précalculées" mais j'avoue que perso, je ne saurais pas faire ça...

Sinon, si tu en as le courage et si cela t'interesse, ce qui pourrait être sympa, c'est d'ajouter une fenêtre qui trace la partie explorée du labyrinthe (gnérateur de carte pour le joueur). Qu'en penses-tu ?
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyVen 18 Nov 2011 - 15:43

Eh bien nous y voilà!
La raison pour laquelle je me suis inscrit sur le forum et que j'ai publié mon générateur de labyrinthe, c'est que je suivais de loin votre projet de jeu collaboratif car j'avais déjà commencé un jeu un peu similaire depuis quelques mois! Et cela m'a énervé quand vous vous ètes mis tous les uns après les autres à le lacher. Voilà pourquoi mon post tombe à point nommé!
Bon, pour ce qui est de mon programme, j'avais il y quelques mois un affichage d'une pièce en 3d, où, on voyait un mur en face, un mur à gauche et un mur à droite avec un plafond et un sol. Sur les murs, suivant dans la salle où on se trouvait, apparaissaient ou pas les portes. Tantôt une à gauche, une à droite, une en face, ou 2portes, etc...
En appuyant sur la flèche haut pour la porte en face, gauche pour la gauche et droite pour la droite, on changeait de salle, et les textures des murs, plafond et sol, changeaint! Si on appuyait sur la touche bas, on fait 1/2 tour et on revenait à la salle d'avant. C'était une manière de se déplacer, et je pouvais faire évoluer un personnage dans chaque salle ou y mettre ce que je désirais. De plus en appuyant sur la barre d'espace, la scene 3d disparaissait et une scene 2d du plan du labyrinthe apparaissait avec un tracé du chemin parcouru et la position où l'on se trouve. En rappuyant sur la barre espace on reviens à la scene 3d.
Mais j'ai pensé qu'évoluer de manière non statique dans le labyrinthe rendrait mon jeu plus attrayant, et c'est le but de mon dernier programme. Tout à l'heure j'ai cru avoir trouvé la solution à mon problème de collision avec les murs , mais je dois y renoncer. Dans la version 0.9.22i3, JACK avait mis les instructions CURVE_ANGLE(DESTINATION, CURRENT, SPEED) et CURVE_VALUE(DESTINATION, CURRENT, SPEED) dont je pouvais me servir, mais dans cette version qu'il a récemment mis en ligne à notre disposition, elles n'y sont plus.
Je vais voir si je peux retrouver la version 0.9.22i3

ça me fait plaisir d'échanger avec toi Smile

A bientôt


Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyVen 18 Nov 2011 - 16:00

C'est un plaisir partagé Smile, mais je pense que ton programme n'interesse pas que moi, nous sommes nombreux à ne pas maitriser la 3D et l'illustration de ton programme doit interesser beaucoup de monde, le problème, c'est que la pratiquant peu, nous sommes peu (je pense à pouvoir vraiment t'aider sur ce sujet, faute de réel mise en pratique, d'autant que les version de Toonic, etc.. arrivaient et semblent encore plus permorfants au niveau de la 3D mais par conséquant nous avons du mal à t'aider dans les problèmes que tu rencontres).
En tout cas le fait d'échanger avec toi m'a redonné envie de mettre les main dedans et d'y consacrer du temps (même si ce week-end, je ne vais de nouveau pas en avoir beaucoup)
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: LABYRINTHE 3D   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 15:32

BONJOUR AMIS PANORAMICIENS. Wink

Dans cette nouvelle version de mon programme d'un labyrinthe en 3d, j'ai enfin pu gèrer les collisions avec les murs! Enfin pas tout à fait, puisque j'ai tout simplement prévu de les éviter pour qu'elles ne se produisent jamais et je me suis cadré toujours au milieu du couloir emprunté. Ainsi, je ne rentre jamais en collision avec un mur.
J'ai ajouté l'option de la barre d'espace qui affiche la "carte" du labyrinthe et permet de s'y repérer. En rappuyant à nouveau sur la barre d'espace vous revenez au mode 3d. (par contre j'ai un bug, c'est selon, l'orientation gauche droite est inversée dans la carte par rapport au mode 3d, et je ne trouve pas l'erreur, donc avis aux amateurs qui peuvent me résoudre ce problème affraid )
Je crois que toutes les remarques dans le code sont assez explicatives et que vous n'aurez pas de problèmes pour le comprendre.
cheers
Code:

' ******************************************************************************
' ******************************************************************************
' ******************* LABYRINTHE 3D version 06**********************************
' ****************** CRÉER PAR bignono le 20/11/2011 ***************************
' *********************** EN BASIC PANORAMIC ***********************************
' ******************************************************************************
' ******************************************************************************



dim ang,d,dtn,f,g,h,i,j,k,n,r,s,v,a(32,22),ax(32,22),ay(32,22),c(4),mur(32,22),trc(32,22),rot,pt,gd
label affiche,attend,trace,moteur,lab,termine,r1,r2,r3,r4,r5,r6,r7,entr,pan1,pan2,pan4,pan8
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne, N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA



' ******************************************************************************
' VALEURS MAXIMALES de h et v pour voir le labyrinthe dans la routine "trace"
' mode écran 800  x 600 --> h=15 ; v=12
' mode écran 1024 x 768 --> h=20 ; v=17
' mode écran 1280 x 800 --> h=15 ; v=12
' mode écran 1366 x 768 --> h=26 ; v=17
' mode écran 1600 x 900 --> h=31 ; v=20
h=30:v=20:n=h*v-1:h=h+1:v=v+1:d=1
for i=1 to h
  for j=1 to v:ax(i,j)=(i*50)-85:ay(i,j)=10+(v*40)-(j*40):next j
next i
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1
      case 2:        gosub pan2
      case 3:        gosub pan1:gosub pan2
      case 4:        gosub pan4
      case 5:        gosub pan1:gosub pan4
      case 6:        gosub pan2:gosub pan4
      case 7:        gosub pan1:gosub pan2:gosub pan4
      case 8:        gosub pan8
      case 9:        gosub pan1:gosub pan8
      case 10:      gosub pan2:gosub pan8
      case 11:      gosub pan1:gosub pan2:gosub pan8
      case 12:      gosub pan4:gosub pan8
      case 13:      gosub pan1:gosub pan4:gosub pan8
      case 14:      gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,10:on_timer 2,moteur
end



' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:
select scancode
case 27:goto termine: ' SORTIE PROGRAMME

case 32:goto trace: ' AFFICHAGE DE LA CARTE ET DU CHEMIN PARCOURU
case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+2:3d_y_rotate 3,rot:3d_y_rotate number_3d_objects,rot:gosub affiche
    until rot=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-2:3d_y_rotate 3,rot:3d_y_rotate number_3d_objects,rot:gosub affiche
    until rot=ang

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+0.25:3d_move 3,0.25:gosub affiche
              until pt=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+0.25:3d_move 3,0.25:gosub affiche
              until pt=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+0.25:3d_move 3,0.25:gosub affiche
              until gd=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+0.25:3d_move 3,0.25:gosub affiche
              until gd=pt
        end_if
    end_if

' TEST DE SORTIE DU LABYRINTHE
  if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
  end_if

' MÉMORISATION DE SON PASSAGE POUR LA CARTE
trc(i,j)=1
end_select
return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' TRACÉ DE LA CARTE ET DU CHEMIN PARCOURU
trace:
hide 1
2d_pen_color 0,0,192:2d_pen_width 3
for g=2 to v
  for f=2 to h
    select a(f,g)
      case 1 :2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40
      case 2 :2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g)
      case 3 :2d_line ax(f,g),ay(f,g)+40,ax(f,g),ay(f,g):2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g)
      case 4 :2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 5 :2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40:2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 6 :2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 7 :2d_line ax(f,g),ay(f,g)+40,ax(f,g),ay(f,g):2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 8 :2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
      case 9 :2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
      case 10:2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
      case 11:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g),ay(f,g):2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g)
      case 12:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 13:2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 14:2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
    end_select
if trc(f,g)=1 then 2d_circle ax(f,g)+25,ay(f,g)+25,2
next f:next g
' 2d_pen_color 255,0,0:2d_line 765,810,815,810
print_locate (h/2)*50-(2*odd(h)*50),(v-1)*40:print "ENTRÉE"
print_locate (h/2)*50-(2*odd(h)*50),0:print "SORTIE"
attend:
wait 100:2d_pen_color 255,0,0:2d_circle ax(i,j)+25,ay(i,j)+25,2
if scancode=32 then show 1:wait 100:goto moteur
if scancode=27 then goto termine
wait 100:2d_pen_color 240,240,240:2d_circle ax(i,j)+25,ay(i,j)+25,2
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate

N'hésitez pas à me faire part de vos remarques, j'y suis très sensible et vos conseils sont toujours les bienvenus. C'est comme ça que je progresse et que dans un esprit de partage je publie mes codes comme certains d'entre vous le font!

A bientôt Sad
Revenir en haut Aller en bas
659_minifly




Nombre de messages : 590
Age : 75
Localisation : Valenciennes Nord
Date d'inscription : 29/04/2010

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 16:40

Bonjour Bignono
J'ai essayé ton programme et il est super. avec murs de différentes textures il est parfait ha oui et un peu de misic et alors
incroyable
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Rectification   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 18:50

Je viens de vérifier mon prog et il y a un mur qui tourne lorsqu'on pivote avec les flèches gauche ou droite

il faut rectifier comme ceci le case 37 et case 39 de la partie "LE PROGRAMME PRINCIPAL"

Code:

case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+2:3d_y_rotate 3,rot:gosub affiche
    until rot=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-2:3d_y_rotate 3,rot:gosub affiche
    until rot=ang

MERCI...
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Rectification 2   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 19:37

une autre petite rectification:

dans la section TRACÉ DE LA CARTE ET DU CHEMIN PARCOURU changer l'expression dans les print_locate

Code:

print_locate (h/2)*50-((2*odd(h)+2*even(h))*50),(v-1)*40:print "ENTRÉE"
print_locate (h/2)*50-((2*odd(h)+2*even(h))*50),0:print "SORTIE"

Merci...
Revenir en haut Aller en bas
JL35




Nombre de messages : 7095
Localisation : 77
Date d'inscription : 29/11/2007

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 21:11

Beau travail bignono, chapeau !
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 22:22

Superbe Smile

J'ai modifié un peu le programme car j'avais parfois un arrêt de Panoramic quand je "revenais" de la carte.
A priori, je n'ai plus le problème en procédant ainsi... J'ai aussi accélérer les déplacement car je suis un grand impatient Smile

J'adore cette version, génial Bignono Smile

Code:

' ******************************************************************************
' ******************************************************************************
' ******************* LABYRINTHE 3D version 06**********************************
' ****************** CRÉER PAR bignono le 20/11/2011 ***************************
' *********************** EN BASIC PANORAMIC ***********************************
' ******************************************************************************
' ******************************************************************************



dim ang,d,dtn,f,g,h,i,j,k,n,r,s,v, affiche_carte
dim a(32,22),ax(32,22),ay(32,22),c(4),mur(32,22),trc(32,22),rot,pt,gd
label affiche,attend,trace,moteur,lab,termine,r1,r2,r3,r4,r5,r6,r7,entr,pan1,pan2,pan4,pan8
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne, N'oubliez pas d'habiller
' votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32
' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA



' ******************************************************************************
' VALEURS MAXIMALES de h et v pour voir le labyrinthe dans la routine "trace"
' mode écran 800  x 600 --> h=15 ; v=12
' mode écran 1024 x 768 --> h=20 ; v=17
' mode écran 1280 x 800 --> h=15 ; v=12
' mode écran 1366 x 768 --> h=26 ; v=17
' mode écran 1600 x 900 --> h=31 ; v=20
h=24:v=20:n=h*v-1:h=h+1:v=v+1:d=1 : affiche_carte=0
for i=1 to h
  for j=1 to v:ax(i,j)=(i*50)-85:ay(i,j)=10+(v*40)-(j*40):next j
next i
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1: gosub pan1
      case 2: gosub pan2
      case 3: gosub pan1:gosub pan2
      case 4: gosub pan4
      case 5: gosub pan1:gosub pan4
      case 6: gosub pan2:gosub pan4
      case 7: gosub pan1:gosub pan2:gosub pan4
      case 8: gosub pan8
      case 9: gosub pan1:gosub pan8
      case 10:gosub pan2:gosub pan8
      case 11:gosub pan1:gosub pan2:gosub pan8
      case 12:gosub pan4:gosub pan8
      case 13:gosub pan1:gosub pan4:gosub pan8
      case 14:gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************


' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,50:on_timer 2,moteur
end


' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:

if affiche_carte = 1 then goto trace

select scancode

case 27:goto termine: ' SORTIE PROGRAMME

case 32: affiche_carte = 1 : ' AFFICHAGE DE LA CARTE ET DU CHEMIN PARCOURU

case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+5:3d_y_rotate 3,rot:gosub affiche
    until rot>=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-5:3d_y_rotate 3,rot:gosub affiche
    until rot<=ang
   
case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+1:3d_move 3,1:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+1:3d_move 3,1:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+1:3d_move 3,1:gosub affiche
              until gd>=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+1:3d_move 3,1:gosub affiche
              until gd>=pt
        end_if
    end_if

' TEST DE SORTIE DU LABYRINTHE
  if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
  end_if

' MÉMORISATION DE SON PASSAGE POUR LA CARTE
trc(i,j)=1
end_select
return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' TRACÉ DE LA CARTE ET DU CHEMIN PARCOURU
trace:
hide 1
2d_pen_color 0,0,192:2d_pen_width 3
for g=2 to v
  for f=2 to h
    select a(f,g)
      case 1 :2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40
      case 2 :2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g)
      case 3 :2d_line ax(f,g),ay(f,g)+40,ax(f,g),ay(f,g):2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g)
      case 4 :2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 5 :2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40:2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 6 :2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 7 :2d_line ax(f,g),ay(f,g)+40,ax(f,g),ay(f,g):2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 8 :2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
      case 9 :2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
      case 10:2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
      case 11:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g),ay(f,g):2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g)
      case 12:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 13:2d_line ax(f,g),ay(f,g),ax(f,g),ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40
      case 14:2d_line ax(f,g),ay(f,g),ax(f,g)+50,ay(f,g):2d_line ax(f,g)+50,ay(f,g),ax(f,g)+50,ay(f,g)+40:2d_line ax(f,g),ay(f,g)+40,ax(f,g)+50,ay(f,g)+40
    end_select
if trc(f,g)=1 then 2d_circle ax(f,g)+25,ay(f,g)+25,2
next f:next g
' 2d_pen_color 255,0,0:2d_line 765,810,815,810
print_locate (h/2)*50-((2*odd(h)+2*even(h))*50),(v-1)*40:print "ENTRÉE"
print_locate (h/2)*50-((2*odd(h)+2*even(h))*50),0:print "SORTIE"

attend:
wait 200:2d_pen_color 255,0,0:2d_circle ax(i,j)+25,ay(i,j)+25,2
if scancode=32
  while scancode=32
  end_while
  wait 20
  affiche_carte=0
  show 1
  goto moteur
end_if
if scancode=27 then goto termine
wait 200:2d_pen_color 240,240,240:2d_circle ax(i,j)+25,ay(i,j)+25,2
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: LABYRINTHE 3D   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 22:26

BONSOIR AMIS PANORAMICIENS Wink

Voici ma toute dernière version. Vous allez décoller!
Il n'y a plus de carte en 2d du labyrinthe. No
Commencez par progresser de quelques cases dans le labyrinthe puis faites demi-tour, et là, miracle, vous avez semé des petites sphères oranges Basketball qui vous indiquent que vous êtes déjà passé par ce couloir.
Vous êtes toujours perdu et vous n'arrivez pas à trouver la sortie, qu'à cela ne tienne, appuyez sur la barre d'espace et envolez-vous! N'oubliez-pas de rappuyez sur la même touche pour atterrir!!!
cheers cheers cheers
Code:

' ******************************************************************************
' ******************************************************************************
' ************************* LABYRINTHE 3D version 07 ***************************
' ********************** CRÉÉ PAR bignono le 20/11/2011 ************************
' **************************** EN BASIC PANORAMIC ******************************
' ******************************************************************************
' ******************************************************************************



dim a(32,22),ang,c(4),d,dtn,gd,h,i,j,k,n,r,s,v,mur(32,22),pt,rot,trc(32,22),w
label affiche,attend,entr,lab,moteur,pan1,pan2,pan4,pan8,r1,r2,r3,r4,r5,r6,r7,termine,trace
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne, N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA



' ******************************************************************************
' le prog peut parfois bugger si h et v sont plus grand (message: Panoramic a cessé de fonctionner)
h=20:v=15:n=h*v-1:h=h+1:v=v+1:d=1
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1
      case 2:        gosub pan2
      case 3:        gosub pan1:gosub pan2
      case 4:        gosub pan4
      case 5:        gosub pan1:gosub pan4
      case 6:        gosub pan2:gosub pan4
      case 7:        gosub pan1:gosub pan2:gosub pan4
      case 8:        gosub pan8
      case 9:        gosub pan1:gosub pan8
      case 10:      gosub pan2:gosub pan8
      case 11:      gosub pan1:gosub pan2:gosub pan8
      case 12:      gosub pan4:gosub pan8
      case 13:      gosub pan1:gosub pan4:gosub pan8
      case 14:      gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,10:on_timer 2,moteur
end

rem (***** cam_position ((h/2)*8),60,9 *****)

' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:
select scancode
case 27:goto termine: ' SORTIE PROGRAMME

case 32:goto trace: ' AFFICHAGE DU PLAN DU LABYRINTHE
case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+2:3d_y_rotate 3,rot:gosub affiche
    until rot=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-2:3d_y_rotate 3,rot:gosub affiche
    until rot=ang

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+0.25:3d_move 3,0.25:gosub affiche
              until pt=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+0.25:3d_move 3,0.25:gosub affiche
              until pt=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+0.25:3d_move 3,0.25:gosub affiche
              until gd=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+0.25:3d_move 3,0.25:gosub affiche
              until gd=pt
        end_if
    end_if
end_select

' TEST DE SORTIE DU LABYRINTHE
if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
end_if

' MÉMORISATION DE SON PASSAGE PAR DES SPHÈRES ORANGES
if trc(i,j)=0
  3d_sphere number_3d_objects+1,0.25
  3d_position number_3d_objects,i*8,1,j*8
  3d_color number_3d_objects,224,128,32
  trc(i,j)=1
end_if

return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' VISION DE HAUT DU LABYRINTHE EN 3D
trace:
  w=4
  repeat
      w=w+0.25:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=70

attend:
if scancode=27 then goto termine
if scancode=32
      repeat
      w=w-0.25:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  goto moteur
end_if
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate

Amusez-vous bien et dites moi ce que vous en pensez!
cheers cheers cheers
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 22:31

J'ai le même problème, quand je reviens après avoir décollé et que je retourne dans le labyrinthe, parfois, Panoramic "cesse de fonctionner", mais la même modification que celle que j'ai mis juste avant (on s'est croisé) doit fonctionner aussi Smile
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Labyrinthe 3d   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 22:39

Tout à fait Jicehel, j'ai fait la même modif, et ça fonctionne bien maintenant!
Merci... cheers
Voici le prog modifié
Code:

' ******************************************************************************
' ******************************************************************************
' ************************* LABYRINTHE 3D version 07 ***************************
' ********************** CRÉÉ PAR bignono le 20/11/2011 ************************
' **************************** EN BASIC PANORAMIC ******************************
' ******************************************************************************
' ******************************************************************************



dim a(32,22),ang,c(4),d,dtn,gd,h,i,j,k,n,r,s,v,mur(32,22),pt,rot,trc(32,22),w,espace
label affiche,attend,entr,lab,moteur,pan1,pan2,pan4,pan8,r1,r2,r3,r4,r5,r6,r7,termine,trace
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne, N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA



' ******************************************************************************
h=20:v=15:n=h*v-1:h=h+1:v=v+1:d=1:espace=0
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1
      case 2:        gosub pan2
      case 3:        gosub pan1:gosub pan2
      case 4:        gosub pan4
      case 5:        gosub pan1:gosub pan4
      case 6:        gosub pan2:gosub pan4
      case 7:        gosub pan1:gosub pan2:gosub pan4
      case 8:        gosub pan8
      case 9:        gosub pan1:gosub pan8
      case 10:      gosub pan2:gosub pan8
      case 11:      gosub pan1:gosub pan2:gosub pan8
      case 12:      gosub pan4:gosub pan8
      case 13:      gosub pan1:gosub pan4:gosub pan8
      case 14:      gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,10:on_timer 2,moteur
end

rem (***** cam_position ((h/2)*8),60,9 *****)

' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:

if espace=1 then goto trace

select scancode
case 27:goto termine: ' SORTIE PROGRAMME

case 32:espace=1: ' AFFICHAGE DU PLAN DU LABYRINTHE
case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+2:3d_y_rotate 3,rot:gosub affiche
    until rot=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-2:3d_y_rotate 3,rot:gosub affiche
    until rot=ang

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+0.25:3d_move 3,0.25:gosub affiche
              until pt=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+0.25:3d_move 3,0.25:gosub affiche
              until pt=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+0.25:3d_move 3,0.25:gosub affiche
              until gd=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+0.25:3d_move 3,0.25:gosub affiche
              until gd=pt
        end_if
    end_if
end_select

' TEST DE SORTIE DU LABYRINTHE
if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
end_if

' MÉMORISATION DE SON PASSAGE PAR DES SPHÈRES ORANGES
if trc(i,j)=0
  3d_sphere number_3d_objects+1,0.25
  3d_position number_3d_objects,i*8,1,j*8
  3d_color number_3d_objects,224,128,32
  trc(i,j)=1
end_if

return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' VISION DE HAUT DU LABYRINTHE EN 3D
trace:
  w=4
  repeat
      w=w+0.25:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=70

attend:
if scancode=27 then goto termine
if scancode=32
      repeat
      w=w-0.25:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
  goto moteur
end_if
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate

C'est bien maintenant, hein! Wink
Revenir en haut Aller en bas
JL35




Nombre de messages : 7095
Localisation : 77
Date d'inscription : 29/11/2007

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 22:49

Pas mal le coup des oranges et de la vue aérienne !
Mais j'ai aussi un plantage de temps en temps 'Panoramic a cessé de fonctionner'...
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 22:57

J'avais encore le problème avec ta dernière version, alors j'ai refais une petite modif Smile
(J'ai remis l’accélération aussi ....)
JL35, avec ce code, ça plante chez toi ?
Code:

' ******************************************************************************
' ******************************************************************************
' ************************* LABYRINTHE 3D version 07 ***************************
' ********************** CRÉÉ PAR bignono le 20/11/2011 ************************
' **************************** EN BASIC PANORAMIC ******************************
' ******************************************************************************
' ******************************************************************************



dim a(32,22),ang,c(4),d,dtn,gd,h,i,j,k,n,r,s,v,mur(32,22),pt,rot,trc(32,22),w,espace
label affiche,attend,entr,lab,moteur,pan1,pan2,pan4,pan8,r1,r2,r3,r4,r5,r6,r7,termine,trace
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne
' N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA


' ******************************************************************************
' VALEURS MAXIMALES de h et v pour voir le labyrinthe dans la routine "trace"
' mode écran 800  x 600 --> h=15 ; v=12
' mode écran 1024 x 768 --> h=20 ; v=17
' mode écran 1280 x 800 --> h=15 ; v=12
' mode écran 1366 x 768 --> h=26 ; v=17
' mode écran 1600 x 900 --> h=31 ; v=20
' ******************************************************************************
h=20:v=15:n=h*v-1:h=h+1:v=v+1:d=1:espace=0
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1
      case 2:        gosub pan2
      case 3:        gosub pan1:gosub pan2
      case 4:        gosub pan4
      case 5:        gosub pan1:gosub pan4
      case 6:        gosub pan2:gosub pan4
      case 7:        gosub pan1:gosub pan2:gosub pan4
      case 8:        gosub pan8
      case 9:        gosub pan1:gosub pan8
      case 10:      gosub pan2:gosub pan8
      case 11:      gosub pan1:gosub pan2:gosub pan8
      case 12:      gosub pan4:gosub pan8
      case 13:      gosub pan1:gosub pan4:gosub pan8
      case 14:      gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,10:on_timer 2,moteur
end

rem (***** cam_position ((h/2)*8),60,9 *****)

' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:

if espace=1 then goto trace

select scancode

case 27:goto termine: ' SORTIE PROGRAMME

case 32:espace=1: ' AFFICHAGE DU PLAN DU LABYRINTHE

case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+5:3d_y_rotate 3,rot:gosub affiche
    until rot>=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-5:3d_y_rotate 3,rot:gosub affiche
    until rot<=ang

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+1:3d_move 3,1:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+1:3d_move 3,1:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+1:3d_move 3,1:gosub affiche
              until gd>=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+1:3d_move 3,1:gosub affiche
              until gd>=pt
        end_if
    end_if
end_select

' TEST DE SORTIE DU LABYRINTHE
if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
end_if

' MÉMORISATION DE SON PASSAGE PAR DES SPHÈRES ORANGES
if trc(i,j)=0
  3d_sphere number_3d_objects+1,0.25
  3d_position number_3d_objects,i*8,1,j*8
  3d_color number_3d_objects,224,128,32
  trc(i,j)=1
end_if

return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' VISION DE HAUT DU LABYRINTHE EN 3D
trace:
  w=4
  repeat
      w=w+1:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=70

attend:
if scancode=27 then goto termine
if scancode=32
  while scancode=32
  end_while
  repeat
      w=w-1:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
  wait 20
  goto moteur
end_if
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 23:05

Pour moi, c'est trop rapide, je suis obligé de remettre à 0.25 au lieu de 1.

Ya toujours le même bug! je cherche
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 23:11

J'ai une idée pour que le jeu puisse être adapté à la vitesse de la machine, remplace tout les 0.25 par une variable (PAS par exemple que tu mets à 0.25 au début, je remplacerais par 1 dans ma version, ma machine est plus vieille ...)
Par contre chez moi avec ma modif, ça ne plante plus
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 23:34

J'ai mis la variable pas à 0.25, et j'ai changé l'interval du timer en le passant de 10 à 100. Il semble que ça ne plante plus!
Il faut tester encore.
Je verrais ça demain. Sleep

Code:


' ******************************************************************************
' ******************************************************************************
' ************************* LABYRINTHE 3D version 07 ***************************
' ********************** CRÉÉ PAR bignono le 20/11/2011 ************************
' **************************** EN BASIC PANORAMIC ******************************
' ******************************************************************************
' ******************************************************************************



dim a(32,22),ang,c(4),d,dtn,gd,h,i,j,k,n,r,s,v,mur(32,22),pt,rot,trc(32,22),w,espace,pas
label affiche,attend,entr,lab,moteur,pan1,pan2,pan4,pan8,r1,r2,r3,r4,r5,r6,r7,termine,trace
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne
' N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA


' ******************************************************************************
' ******************************************************************************
h=20:v=15:n=h*v-1:h=h+1:v=v+1:d=1:espace=0:pas=0.25
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1
      case 2:        gosub pan2
      case 3:        gosub pan1:gosub pan2
      case 4:        gosub pan4
      case 5:        gosub pan1:gosub pan4
      case 6:        gosub pan2:gosub pan4
      case 7:        gosub pan1:gosub pan2:gosub pan4
      case 8:        gosub pan8
      case 9:        gosub pan1:gosub pan8
      case 10:      gosub pan2:gosub pan8
      case 11:      gosub pan1:gosub pan2:gosub pan8
      case 12:      gosub pan4:gosub pan8
      case 13:      gosub pan1:gosub pan4:gosub pan8
      case 14:      gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,100:on_timer 2,moteur
end


' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:

if espace=1 then goto trace

select scancode

case 27:goto termine: ' SORTIE PROGRAMME

case 32:espace=1: ' AFFICHAGE DU PLAN DU LABYRINTHE

case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+2:3d_y_rotate 3,rot:gosub affiche
    until rot>=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-2:3d_y_rotate 3,rot:gosub affiche
    until rot<=ang

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+pas:3d_move 3,pas:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+pas:3d_move 3,pas:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+pas:3d_move 3,pas:gosub affiche
              until gd>=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+pas:3d_move 3,pas:gosub affiche
              until gd>=pt
        end_if
    end_if
end_select

' TEST DE SORTIE DU LABYRINTHE
if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
end_if

' MÉMORISATION DE SON PASSAGE PAR DES SPHÈRES ORANGES
if trc(i,j)=0
  3d_sphere number_3d_objects+1,0.25
  3d_position number_3d_objects,i*8,1,j*8
  3d_color number_3d_objects,224,128,32
  trc(i,j)=1
end_if

return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8,8,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' VISION DE HAUT DU LABYRINTHE EN 3D
trace:
  w=4
  repeat
      w=w+pas:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=70

attend:
if scancode=27 then goto termine
if scancode=32
  while scancode=32
  end_while
  repeat
      w=w-pas:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
  wait 20
  goto moteur
end_if
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate
Revenir en haut Aller en bas
Invité
Invité




Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyDim 20 Nov 2011 - 23:51

Bonsoir,
C'est un travail formidable que vous faites.
Je ne cherche pas à déboguer, mais sur le programme de Jicehel, celà plante à la ligne 150, en arrivant au return. A toute fin utile si vous ne le savez pas.

En tout cas, c'est bien pensé! cheers
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyLun 21 Nov 2011 - 0:37

Bon, j'espère qu'avec les dernières modifs ça ne plante plus pour personne, le boulot et l'artiste, c'est bignono, je modifie juste un peu son programme.
Là, j'ai rajouté "pasv" pour que le "zoom out / zoom in" sur la labyrinthe puisse être réglé indépendamment du déplacement. J'ai modifié un peu la taille des mur aussi pour avoir moins d'effet de mur côte à côte dans certains angles. Perso, je n'ai plus de "plantage" lors de mes tests
Code:
' ******************************************************************************
' ******************************************************************************
' ************************* LABYRINTHE 3D version 07 ***************************
' ********************** CRÉÉ PAR bignono le 20/11/2011 ************************
' **************************** EN BASIC PANORAMIC ******************************
' ******************************************************************************
' ******************************************************************************


dim a(32,22),ang,c(4),d,dtn,gd,h,i,j,k,n,r,s,v,mur(32,22),pt,rot,trc(32,22),w,espace,pas, pasv
label affiche,attend,entr,lab,moteur,pan1,pan2,pan4,pan8,r1,r2,r3,r4,r5,r6,r7,termine,trace
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne
' N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA


' ******************************************************************************
' ******************************************************************************
h=20:v=15:n=h*v-1:h=h+1:v=v+1:d=1:espace=0:pas=0.5 : pasv=2 : ' "pas" : vitesse de déplacement dans le labyrinthe
                                                            : ' "pasv": vitesse de zoom verticale
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1
      case 2:        gosub pan2
      case 3:        gosub pan1:gosub pan2
      case 4:        gosub pan4
      case 5:        gosub pan1:gosub pan4
      case 6:        gosub pan2:gosub pan4
      case 7:        gosub pan1:gosub pan2:gosub pan4
      case 8:        gosub pan8
      case 9:        gosub pan1:gosub pan8
      case 10:      gosub pan2:gosub pan8
      case 11:      gosub pan1:gosub pan2:gosub pan8
      case 12:      gosub pan4:gosub pan8
      case 13:      gosub pan1:gosub pan4:gosub pan8
      case 14:      gosub pan2:gosub pan4:gosub pan8
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ***  Initialisation et création d'un timer pour gérer les déplacements    ***
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,100:on_timer 2,moteur
end


' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:

if espace=1 then goto trace

select scancode

case 27:goto termine: ' SORTIE PROGRAMME

case 32:espace=1: ' AFFICHAGE DU PLAN DU LABYRINTHE

case 37: ' FLECHE GAUCHE = ROTATION A GAUCHE
    ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+6*pas:3d_y_rotate 3,rot:gosub affiche
    until rot>=ang

case 39: ' FLECHE DROITE = ROTATION A DROITE
    ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-6*pas:3d_y_rotate 3,rot:gosub affiche
    until rot<=ang

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+pas:3d_move 3,pas:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+pas:3d_move 3,pas:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+pas:3d_move 3,pas:gosub affiche
              until gd>=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+pas:3d_move 3,pas:gosub affiche
              until gd>=pt
        end_if
    end_if
end_select

' TEST DE SORTIE DU LABYRINTHE
if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
end_if

' MÉMORISATION DE SON PASSAGE PAR DES SPHÈRES ORANGES
if trc(i,j)=0
  3d_sphere number_3d_objects+1,0.25
  3d_position number_3d_objects,i*8,1,j*8
  3d_color number_3d_objects,224,128,32
  trc(i,j)=1
end_if

return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),4,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE
pan1:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' VISION DE HAUT DU LABYRINTHE EN 3D
trace:
  w=4
  repeat
      w=w+pasv:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=70

attend:
if scancode=27 then goto termine
if scancode=32
  while scancode=32
  end_while
  repeat
      w=w-pasv:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
  wait 20
  goto moteur
end_if
goto attend

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate
Revenir en haut Aller en bas
jpcr

jpcr


Nombre de messages : 276
Age : 57
Localisation : Val de Marne (94)
Date d'inscription : 06/05/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyLun 21 Nov 2011 - 9:08

bravo!
Revenir en haut Aller en bas
http://jeanpierre.creis.free.fr/Panoramic/Panoramic.html
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyLun 21 Nov 2011 - 13:03

Pour le case, j'avais oublié de recopié, mais j'avais modifié comme ça suite aux infos transmis dans le post de Bignono qui expliquait comment étaient calculés les murs:
Code:
    select a(i,j)
'
'      CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
'      LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
'
      case 1:        gosub pan1                        : ' mur de gauche (G)
      case 2:        gosub pan2                        : ' mur du bas    (B)
      case 3:        gosub pan1:gosub pan2            : ' G+B
      case 4:        gosub pan4                        : ' mur de droite (D)
      case 5:        gosub pan1:gosub pan4            : ' G+D
      case 6:        gosub pan2:gosub pan4            : ' B+D
      case 7:        gosub pan1:gosub pan2:gosub pan4  : ' G+B+D (cul de sac en u)
      case 8:        gosub pan8                        : ' mur du haut  (H)
      case 9:        gosub pan1:gosub pan8            : ' G+H
      case 10:      gosub pan2:gosub pan8            : ' B+H
      case 11:      gosub pan1:gosub pan2:gosub pan8  : ' G+B+H (cul de sac en [)
      case 12:      gosub pan4:gosub pan8            : ' D+H
      case 13:      gosub pan1:gosub pan4:gosub pan8  : ' G+D+H (cul de sac en n)
      case 14:      gosub pan2:gosub pan4:gosub pan8  : ' B+D+H (cul de sac en ])
    end_select
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

Labyrinth - Page 2 Empty
MessageSujet: LABYRINTHE 3D   Labyrinth - Page 2 EmptyLun 21 Nov 2011 - 13:34

BONJOUR, AMIS PANORAMICIENS

Merci Jicehel pour tes modifs. En fait, ce qui plantait le programme, scratch c'était l'interval du timer. C'est pour cela que je l'ai passé de 10 à 100 (ayant même vu qu'à 50 et 80 ça plantait aussi).
D'après ce que je constate, les timer ne font pas bon ménage avec les boucles du genre for...next et repeat...until. Je crois que pendant l'éxécution d'une boucle, toute autre opération ou évènement est impossible, hormis ceux dans la boucle. Donc en règlant l'interval du timer, on laisse le temps au processeur d'éxécuter la boucle commandée par Panoramic. Du moins, c'est ce que je crois comprendre, mais je ne suis pas sure de cette explication. Donc
corrige-moi si je me trompe!

Bon maintenant, j'ai rajouté un petit quelque chose...
Oui, dans votre vision en hauteur du labyrinthe, vous pouvez appuyer sur les flèches gauche ou droite, et tout le labyrinthe pivote. Ainsi vous pouvez vous orienter sur la direction que vous voulez prendre maintenant.
Génial, non?
cheers cheers cheers
Code:

' ******************************************************************************
' ******************************************************************************
' ************************* LABYRINTHE 3D version 08 ***************************
' ********************** CRÉÉ PAR bignono le 21/11/2011 ************************
' **************************** EN BASIC PANORAMIC ******************************
' ******************************************************************************
' ******************************************************************************


dim ang,d,dtn,espace,gd,h,i,j,k,n,pas,pasv,r,s,v,pt,rot,w
dim a(32,22),c(4),mur(32,22),trc(32,22)
label affiche,attend,droite,entr,gauche,lab,moteur,pan1,pan2,pan4,pan8,pivot
label r1,r2,r3,r4,r5,r6,r7,termine,trace
scene3d 1:full_space 0:full_space 1:light_position 0,1500,0
3d_skybox 1:' ---> Si vous voulez définir un "SKYBOX 1" ici sur cette ligne
' N'oubliez pas d'habiller votre skybox avec les commandes 3d_load_texture_back, bottom, front, left, right et top
3d_plane 2:3d_scale 2,500,500,1:3d_x_rotate 2,90:3d_y_position 2,0:3d_color 2,0,0,32: ' ---> CHANGEZ LE 3D_COLOR 2 PAR 3D_LOAD_TEXTURE 2,"FICHIER BMP OU JPG" ET N'OUBLIEZ PAS LES COMMANDES 3D_U_TILES & 3D_v_TILES
3d_cube 3,1:3d_mesh 4:3d_hide 3: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA


' ******************************************************************************
' ************************ INITIALISATION DES VARIABLES ************************
' ******************************************************************************
' ** h et v représentent les dimensions du labyrinthe (vous pouvez les modifier,
' mais plus le labyrinthe est grand, plus le programme ralentit!) **************
' ****** pas : sert à règler la vitesse de déplacement dans le labyrinthe ******
' ****** pasv: sert à règler la vitesse du zoom vertical ***********************
h=20:v=15:n=h*v-1:h=h+1:v=v+1:d=1:w=4:espace=0:pas=0.25:pasv=1
gosub lab
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 5,"ENTRÉE":3d_color 5,0,0,255:3d_y_rotate 5,180
3d_position 5,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 6,"SORTIE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,(v*8)+4

' CAS 1 = MUR GAUCHE, CAS 2 = MUR ARRIÈRE, CAS 4 = MUR DROIT, CAS 8 = MUR FACE
' LES AUTRES CAS, C'EST UNE ADDITION; EX: CAS 3 = CAS 1 + CAS 2
for j=2 to v
  for i=2 to h
  if j=2 and i=int(h/2) or j=v and i=int(h/2) then goto entr
    select a(i,j)
      case 1:        gosub pan1                      : ' mur de gauche (G)
      case 2:        gosub pan2                      : ' mur du bas    (B)
      case 3:        gosub pan1:gosub pan2          : ' G+B
      case 4:        gosub pan4                      : ' mur de droite (D)
      case 5:        gosub pan1:gosub pan4          : ' G+D
      case 6:        gosub pan2:gosub pan4          : ' B+D
      case 7:        gosub pan1:gosub pan2:gosub pan4: ' G+B+D (cul de sac en u)
      case 8:        gosub pan8                      : ' mur du haut  (H)
      case 9:        gosub pan1:gosub pan8          : ' G+H
      case 10:      gosub pan2:gosub pan8          : ' B+H
      case 11:      gosub pan1:gosub pan2:gosub pan8: ' G+B+H (cul de sac en [)
      case 12:      gosub pan4:gosub pan8          : ' D+H
      case 13:      gosub pan1:gosub pan4:gosub pan8: ' G+D+H (cul de sac en n)
      case 14:      gosub pan2:gosub pan4:gosub pan8: ' B+D+H (cul de sac en ])
    end_select
entr:
  next i
next j
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ** Initialisation position de départ et création d'un timer pour gérer les  **
' * déplacements. Si le programme plante augmentez la valeur du timer_interval *
' ******************************************************************************
i=int(h/2):j=1:dtn=1:a(i,j)=a(i,j)-2:a(i,v)=a(i,v)-2
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,100:on_timer 2,moteur
end


' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:

if espace=1 then goto trace

select scancode

case 27:goto termine: ' SORTIE PROGRAMME

case 32:espace=1: ' AFFICHAGE DU PLAN DU LABYRINTHE

case 37:gosub gauche: ' FLECHE GAUCHE = ROTATION A GAUCHE

case 39:gosub droite: ' FLECHE DROITE = ROTATION A DROITE

case 38: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
    if dtn=1
        if a(i,j)=0 or a(i,j)=1 or a(i,j)=4 or a(i,j)=5 or a(i,j)=8 or a(i,j)=9 or a(i,j)=12 or a(i,j)=13
            pt=j*8:j=j+1:gd=j*8
              repeat
                pt=pt+pas:3d_move 3,pas:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=2
        if a(i,j)<4 or a(i,j)>7 and a(i,j)<12
          pt=i*8:i=i+1:gd=i*8
              repeat
                pt=pt+pas:3d_move 3,pas:gosub affiche
              until pt>=gd
        end_if
    end_if

    if dtn=3
        if a(i,j)<8
            pt=j*8:j=j-1:gd=j*8
              repeat
                gd=gd+pas:3d_move 3,pas:gosub affiche
              until gd>=pt
        end_if
    end_if

    if dtn=4
        if odd(a(i,j))=0
            pt=i*8:i=i-1:gd=i*8
              repeat
                gd=gd+pas:3d_move 3,pas:gosub affiche
              until gd>=pt
        end_if
    end_if
end_select

' TEST DE SORTIE DU LABYRINTHE
if j=v+1
  beep_exclamation:message "BRAVO, VOUS ETES SORTI DU LABYRINTHE!":goto termine
end_if

' MÉMORISATION DE SON PASSAGE PAR DES SPHÈRES ORANGES
if trc(i,j)=0
  3d_sphere number_3d_objects+1,0.25
  3d_position number_3d_objects,i*8,1,j*8
  3d_color number_3d_objects,224,128,32
  trc(i,j)=1
end_if

return
' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' *********************    LES ROUTINES      ***********************************
' ******************************************************************************

' CALCUL DES POSITIONS DES VÉHICULES MOTEUR ET CAMÉRA
affiche:
3d_position 4,o3d_x_position(3),o3d_y_position(3),o3d_z_position(3):3d_rotate 4,o3d_x_rotate(3),o3d_y_rotate(3),o3d_z_rotate(3)
3d_move 4,1:cam_position o3d_x_position(3),w,o3d_z_position(3):point_position o3d_x_position(4),4,o3d_z_position(4)
return

' CRÉATION DES MURS DU LABYRINTHE : Vous pouvez supprimer les 3d_color et mettre
' à la place un 3d_load_texture si vous voulez habillez les murs!!!
pan1:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8)-4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan2:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8),4,(j*8)+4
return
pan4:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8)+4,4,(j*8)
3d_y_rotate number_3d_objects,90:3d_color number_3d_objects,96,0,0
return
pan8:
3d_box number_3d_objects+1,8.9,8.9,1:3d_position number_3d_objects,(i*8),4,(j*8)-4
return

' VISION DE HAUT DU LABYRINTHE EN 3D
trace:

  repeat
      w=w+pasv:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=70

attend:
if scancode=27 then goto termine
if scancode=32
'  while scancode=32
'  end_while
  repeat
      w=w-pasv:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
'  wait 20
  goto moteur
end_if
if scancode=37 then gosub gauche
if scancode=39 then gosub droite
goto attend

' ROTATION A GAUCHE
gauche:
ang=rot+90:dtn=dtn+1:if dtn>4 then dtn=1
    repeat
        rot=rot+6*pas:3d_y_rotate 3,rot:if w>4 then gosub pivot
        gosub affiche
    until rot>=ang
return

' ROTATION A DROITE
droite:
 ang=rot-90:dtn=dtn-1:if dtn<1 then dtn=4
    repeat
        rot=rot-6*pas:3d_y_rotate 3,rot:if w>4 then gosub pivot
        gosub affiche
    until rot<=ang
return

' ROTATION DE LA CAMÉRA LORS DE LA VISION DE HAUT
pivot:
cam_position o3d_x_position(3),o3d_y_position(3)+w,o3d_z_position(3)
return

' GÉNÉRATION DU LABYRINTHE
lab:
for j=1 to v+1:a(1,j)=4:a(h+1,j)=1:next j
for i=2 to h:a(i,v+1)=8:a(i,1)=2:for j=2 to v:a(i,j)=15:next j:next i
r=int(h/2+1):s=int(v/2+1):a(r,s)=15
for k=1 to n
r1:
  i=0
  if a(r-1,s)=15 then i=i+1 :c(i)=1
  if a(r,s-1)=15 then i=i+1 :c(i)=2
  if a(r+1,s)=15 then i=i+1 :c(i)=3
  if a(r,s+1)=15 then i=i+1 :c(i)=4
  if i=0 then goto r2
  if i<>1 then i=int(rnd(i)+1)
  select c(i)
      case 1 :a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2):r=r-1:a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4
      case 2 :a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8:s=s-1:a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2
      case 3 :a(r,s)=a(r,s)-(int(a(r,s)/4)-int(int(a(r,s)/4)/2)*2)*4:r=r+1:a(r,s)=a(r,s)-(int(a(r,s))-int(int(a(r,s))/2)*2)
      case 4 :a(r,s)=a(r,s)-(int(a(r,s)/2)-int(int(a(r,s)/2)/2)*2)*2:s=s+1:a(r,s)=a(r,s)-(int(a(r,s)/8)-int(int(a(r,s)/8)/2)*2)*8
  end_select
  goto r7
r2:
  if d=-1 then goto r3
  if r<>h then goto r5
  if s<>v then goto r4
  r=2:s=2:goto r6
r3:
  if r<>2 then goto r5
  if s<>v then goto r4
  r=h:s=2: goto r6
r4:
  s=s+1:d=-1*d:goto r6
r5:
  r=r+d
r6:
  if a(r,s)=15 then goto r2
  goto r1
r7:
  mur(r,s)=int(rnd(6)+1)
  if mur(r,s)=mur(r-1,s) or mur(r,s)=mur(r+1,s) or mur(r,s)=mur(r,s-1) or mur(r,s)=mur(r,s+1) then goto r7
next k
return

' SORTIE DU PROGRAMME
termine:
timer_off 2:terminate
A bientôt...
Vos réactions sont les bienvenues!!! Very Happy

PS: Je viens juste de voir les modifs du case des murs, et je les ai intégré au programme ci-dessus, Merci encore
Revenir en haut Aller en bas
JL35




Nombre de messages : 7095
Localisation : 77
Date d'inscription : 29/11/2007

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyLun 21 Nov 2011 - 14:03

Effectivement, il semble que ça ne plante plus...
Enfin c'est juste moi qui me plante pour trouver la sortie, c'est qu'il est plutôt compliqué ton labyrinthe ! Il n'y a pas une option 'Le Labyrinthe pour les Nuls' avec moins de cases ?.... c'est un peu frustrant. Et aussi affichage de la boussole, je suis vite perdu dans le dédale, malgré le fil d'Ariane...

Beau boulot en tout cas, c'est impeccable.
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 EmptyLun 21 Nov 2011 - 14:06

Je teste ce soir, ça l'air sympa. Tu ne remet pas le monstre dans ton laby 3D (Il suffit de faire un carré que l'on texture avec une image de monstre dans un premier temps et que tu déplace selon le même principe que dans ton Laby 2D ...).
Revenir en haut Aller en bas
Contenu sponsorisé





Labyrinth - Page 2 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 2 Empty

Revenir en haut Aller en bas
 
Labyrinth
Revenir en haut 
Page 2 sur 4Aller à la page : Précédent  1, 2, 3, 4  Suivant
 Sujets similaires
-
» FORT LABYRINTH

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Vos sources, vos utilitaires à partager-
Sauter vers: