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 4 Emptypar Klaus Aujourd'hui à 12:43

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

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

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

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

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

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

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

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

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

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

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

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

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

» Bug sur DIM_LOCAL ?
Labyrinth - Page 4 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
-21%
Le deal à ne pas rater :
LEGO® Icons 10329 Les Plantes Miniatures, Collection Botanique
39.59 € 49.99 €
Voir le deal

 

 Labyrinth

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

bignono


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

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 21:32

bonsoir amis panoramiciens

Maintenant le glouton se déplace normalement sans traverser les murs (voir avec la vision de haut), mais le prog plante au bout d'un certain nombre de déplacement. Je ne sais pas pourquoi??? J'ai changé la valeur du timer interval, créé un second timer pour le glouton, etc..., rien n'y fait. J'en fini par me demander si ce n'est pas l'instruction scancode qui poserait problème???
Si quelqu'un peut jeter un coup d'oeil et m'apporter une réponse.
Jicehel, pour les rotations du glouton, je verrais plus tard, ce n'est pas très compliqué à faire. Le problème actuel, c'est de comprendre pourquoi le prog plante et je ne saisis pas pourquoi.
Si Nardo avait un début d'explication, j'y verrais plus clair.
Code:

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

dim ang,d,dtn,espace,f,g,gd,glouton,h,i,j,k,n,pas,pasv,r,s,sd,v,pt,rot,w, c(4),mpt,mgd
label affiche,attend,droite,entr,gauche,glouton,glouton2,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_cube 4,1:3d_hide 3:3d_hide 4: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA
3d_sphere 5,1:3d_color 5,0,96,0:' CRÉATION DU GLOUTON VERT MANGEUR D'ORANGES


' ******************************************************************************
' ************************ 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:glouton=0
dim a(h+1,v+1),mur(h+1,v+1),trc(h+1,v+1),trn(h+1,v+1),gln(h,v)
gosub lab

' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 6,"ENTRÉE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 7,"SORTIE":3d_color 7,0,0,255:3d_y_rotate 7,180
3d_position 7,((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
  gln(i,j)=a(i,j)
  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
f=i:g=j:sd=1:' f et g position départ du glouton vert, sd son sens de déplacement
3d_position 5,((h/2)*8)-(3*odd(h)),4,g*8
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 and j < v+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 and i < h  and j > 1
        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 and j > 2
        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 and i > 2 and j > 1
        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
    wait 50
    end_if
end_select
 3d_position 3, i*8,4,j*8

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

glouton=glouton+1:if glouton=5 then gosub glouton

' 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:trn(i,j)=number_3d_objects
end_if

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

' Gestion déplacement du glouton vert (le monstre) qui mange vos oranges
glouton:
select sd

  case 1
    mpt=g*8:g=g+1:mgd=g*8:gosub glouton2
  if gln(f,g)= 2 or gln(f,g)=4 or gln(f,g)=6 then sd=2
  if gln(f,g)= 3 then sd=4
  if gln(f,g)= 7 then sd=3

  case 2
    mgd=f*8:f=f-1:mpt=f*8:gosub glouton2
  if gln(f,g)= 1 or gln(f,g)=2 or gln(f,g)=3 then sd=3
  if gln(f,g)= 9 then sd=1
  if gln(f,g)=11 then sd=4

  case 3
    mgd=g*8:g=g-1:mpt=g*8:gosub glouton2
  if gln(f,g)= 1 or gln(f,g)=8 or gln(f,g)=9 then sd=4
  if gln(f,g)=12 then sd=2
  if gln(f,g)=13 then sd=1

  case 4
    mpt=f*8:f=f+1:mgd=f*8:gosub glouton2
  if gln(f,g)= 4 or gln(f,g)=8 or gln(f,g)=12 then sd=1
  if gln(f,g)= 6 then sd=3
  if gln(f,g)=14 then sd=2

  end_select
glouton=0
return

glouton2:
if sd=1
    repeat
        mpt=mpt+pas:3d_position 5,f*8,4,mpt
    until mpt>=mgd
end_if
if sd=2
    repeat
        mgd=mgd-pas:3d_position 5,mgd,4,g*8
    until mgd<=mpt
end_if
if sd=3
    repeat
        mgd=mgd-pas::3d_position 5,f*8,4,mgd
    until mgd<=mpt
end_if
if sd=4
    repeat
        mpt=mpt+pas:3d_position 5,mpt,4,g*8
    until mpt>=mgd
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
  repeat
      w=w-pasv:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
  goto moteur
end_if

if scancode=37 then gosub gauche

if scancode=39 then gosub droite

glouton=glouton+1:if glouton=4 then gosub glouton
wait 100

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
Revenir en haut Aller en bas
Jicehel

Jicehel


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

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 21:53

Argh, j'avais la même chose hier à un moment, ça marche bien au niveau du déplacement sauf qu'au début, le glouton traverse le premier mur qu'en il y en a un dans la première pièce ... Je pense que tu dois faire un test au début pour donner une direction après le premier déplacement pourquoi remet tu le glouton 2 ? il ne seet à rien puisque tu refait un test, autant le mettre directement dans ton case, non ?
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 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 22:10

Bonsoir Jicehel,
Il a déjà sa direction de départ sd=1 dans la rubrique "Initialisation position de départ et création d'un timer pour gérer les déplacements". Je l'ai placé là, pour voir comment il se comporte en faisant les tests, mais à terme il devrait partir de l'opposé du labyrinthe ou bien d'une case tirée aléatoirement.
Si je remet la procédure glouton2 c'est que j'ai prévu autre chose dans la procédure glouton. C'est après que je verrais s'il est possible de réintégrer cette procédure dans le case.
Bon pour le moment, je crois que c'est l'heure d'aller me reposer. Bonne nuit à tous. Sleep
Revenir en haut Aller en bas
Invité
Invité




Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 22:27

Bonsoir.
C'est difficile de répondre, pourtant je suis persuadé, et celà depuis l'autre fois lorsque j'ai répondu que le programme s’arrêtait à la ligne 150, qu'il s'agit d'un problème de structure. Aujourd'hui c'est à la ligne 159 qu'il sort du programme.

Je peux me tromper mais pour moi c'est avec le timer. Personnellement lorsque j'utilise un timer pour lancer le programme, lorsqu'il a fait son travail on l’arrête. On est alors en mode évènementiel. Mais là on gère le programme, soit par un autre timer, soit en le branchant sur le programme de gestion. Ici on a l'impression que tant que le timer commande, le programme se poursuit, mais si il y a un temps d'attente, il n'a plus de branchement et s’arrête, C'est surement le cas, car ce n'est une erreur de codage qui l’arrête, mais lorsqu'il arrive à un return, et je pense à un return dans le vide LIGNE 159. C'est mon programme en mode teste qui me le dit.

Maintenant je ne fais que tester mon programme, pas le votre. Et j'ai peut-être tord dans mes conclusions.
Revoyez si vous ne pouvez pas faire une procédure de commandement une fois lancé.
Depuis le temps que je fais des programmes, ou que j'en regarde, cela semble structurel.
Revenir en haut Aller en bas
Nardo26

Nardo26


Nombre de messages : 2294
Age : 55
Localisation : Valence
Date d'inscription : 02/07/2010

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 22:39

Pour plus de tranquillité, mettre un timer_off en début de procédure et revalider le timer en fin de proc...
Un timer spécifique pour le glouton : ok ! ca ameliore les choses (avec une base de temps plus grande)

Pour le scancode ? c'est peut être une piste...
voir si il ne faudrait pas gérer plutôt les déplacements sur un événement clavier ON_KEY_UP par exemple...


EDIT :
J'ai l'impression que si on mémorise le scancode dans une variable et qu'on ne fait appel ensuite qu'a cette variable, cela coince moins... mais c'est peut être qu'une impression...
Revenir en haut Aller en bas
http://nardo26.lescigales.org
Jicehel

Jicehel


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

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 23:03

Fait, voilà le code en plus j'ai rajouté des cas pour que le glouton ne traverse pas les premiers murs Smile
Edit: Petite modif suite à la remarque de Nardo ci dessous:
Code:

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

dim ang,d,dtn,espace,f,g,gd,h,i,j,k,n,pas,pasv,r,s,sd,v,pt,rot,w, c(4),mpt,mgd, touche, glouton
label affiche,attend,droite,entr,gauche,glouton,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_cube 4,1:3d_hide 3:3d_hide 4: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA
3d_sphere 5,1:3d_color 5,0,96,0:' CRÉATION DU GLOUTON VERT MANGEUR D'ORANGES
dim debug: debug = 1
if Debug = 1
  form 500: width 500, 150 : height 500, 200: top 500, 3  : left 500,3
  for i = 1 to 8
    alpha 500 + i: parent 500 + i,500: height 500 + i, 17 : top 500 + i, (17*i) - 14  : left 500 + i,3
  next i
  caption 501,"Glouton:" + str$(Glouton) : caption 504,"Joueur :"
end_if

' ******************************************************************************
' ************************ 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.75:pasv=1 : glouton = 0 : ang = 0 : rot = 0
dim a(h+1,v+1),mur(h+1,v+1),trc(h+1,v+1),trn(h+1,v+1),gln(h,v)
gosub lab

' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 6,"ENTRÉE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 7,"SORTIE":3d_color 7,0,0,255:3d_y_rotate 7,180
3d_position 7,((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
  gln(i,j)=a(i,j)
  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
f=i:g=j:sd=1:' f et g position départ du glouton vert, sd son sens de déplacement
3d_position 5,((h/2)*8)-(3*odd(h)),4,g*8
3d_position 3,((h/2)*8)-(3*odd(h)),4,j*8:gosub affiche
timer 2:timer_interval 2,70:on_timer 2,moteur
timer 3:timer_interval 3,70:on_timer 3,attend : timer_off 3
end

' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:
timer_off 2

glouton  = glouton + 1

if debug = 1
  caption 501,"Glouton:" + str$(Glouton) : caption 504,"Joueur :"
  caption 502, "f=" + str$(f) + "; g=" + str$(g) + "; sd=" + str$(sd)
  caption 505, "dtn =" + str$(dtn) + "; i=" + str$(i) + "; j=" + str$(j)
  caption 506, "a(i,j) =" + str$(a(i,j))
  caption 508, "Execute moteur"
end_if
if espace=1 then goto trace

touche = scancode

select touche

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 and j < v+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 and i < h  and j > 1
        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 and j > 2
        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 and i > 2 and j > 1
        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
    wait 50
    end_if
end_select

if debug = 1
  caption 505, "dtn =" + str$(dtn) + "; i=" + str$(i) + "; j =" + str$(j)
  caption 506, "a(i,j) =" + str$(a(i,j))
end_if

3d_position 3, i*8,4,j*8

' 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:trn(i,j)=number_3d_objects
end_if

if glouton = 5 then gosub glouton

timer_on 2

return

' ******************************************************************************
' ******************************************************************************

' Gestion déplacement du glouton vert (le monstre) qui mange vos oranges
glouton:

glouton = 0
if debug = 1
  caption 501,"Glouton:" + str$(Glouton) : caption 504,"Joueur :"
  caption 502, "f=" + str$(f) + "; g=" + str$(g) + "; sd=" + str$(sd)
  caption 505, "dtn =" + str$(dtn) + "; i=" + str$(i) + "; j=" + str$(j)
  caption 506, "a(i,j) =" + str$(a(i,j))
  caption 508, "Execute glouton"
end_if


select sd

  case 1
    mpt=g*8:g=g+1:mgd=g*8
    repeat
        mpt=mpt+pas:3d_position 5,f*8,4,mpt
    until mpt>=mgd
    if gln(f,g)= 2 or gln(f,g)=4 or gln(f,g)=6 or gln(f,g)=10 or gln(f,g)=14 then sd=2
    if gln(f,g)= 3 then sd=4
    if gln(f,g)= 7 then sd=3
    if debug = 1
      caption 503, "gln(f,g+1)=" + str$(gln(f,g)) + "; sd=" + str$(sd)
    end_if

  case 2
    mgd=f*8:f=f-1:mpt=f*8
    repeat
        mgd=mgd-pas:3d_position 5,mgd,4,g*8
    until mgd<=mpt
    if gln(f,g)= 1 or gln(f,g)=2 or gln(f,g)=3 then sd=3
    if gln(f,g)= 9 then sd=1
    if gln(f,g)=11 then sd=4
    if debug = 1
      caption 503, "gln(f-1,g)=" + str$(gln(f,g)) + "; sd=" + str$(sd)
    end_if

  case 3
    mgd=g*8:g=g-1:mpt=g*8
    repeat
        mgd=mgd-pas::3d_position 5,f*8,4,mgd
    until mgd<=mpt
    if gln(f,g)= 1 or gln(f,g)=8 or gln(f,g)=9 then sd=4
    if gln(f,g)=12 then sd=2
    if gln(f,g)=13 then sd=1
    if debug = 1
      caption 503, "gln(f,g-1)=" + str$(gln(f,g)) + "; sd=" + str$(sd)
    end_if

  case 4
    mpt=f*8:f=f+1:mgd=f*8
    repeat
        mpt=mpt+pas:3d_position 5,mpt,4,g*8
    until mpt>=mgd
    if gln(f,g)= 4 or gln(f,g)=8 or gln(f,g)=12 then sd=1
    if gln(f,g)= 6 then sd=3
    if gln(f,g)=14 then sd=2
    if debug = 1
      caption 503, "gln(f+1,g)=" + str$(gln(f,g)) + "; sd=" + str$(sd)
    end_if

  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),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:

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

timer_on 3

attend:
touche = 0
if debug = 1
  caption 501,"Glouton:" + str$(Glouton) : caption 504,"Joueur :"
  caption 502, "f=" + str$(f) + "; g=" + str$(g) + "; sd=" + str$(sd)
  caption 505, "dtn =" + str$(dtn) + "; i=" + str$(i) + "; j=" + str$(j)
  caption 506, "a(i,j) =" + str$(a(i,j))
  caption 508, "Execute attend"
end_if

glouton  = glouton + 1
touche = scancode
if touche=27 then goto termine
if touche=32
  timer_off 3
  repeat
  until scancode <> 32
  repeat
      cam_position o3d_x_position(3),w,o3d_z_position(3): w=w-pasv : display
  until w<=4
  w = 4: cam_position o3d_x_position(3),w,o3d_z_position(3): display
  touche = scancode
  if debug = 1
    caption 508, "Execute -Touche = 32-"
  end_if
  goto moteur
end_if

if touche=37 then gosub gauche

if touche=39 then gosub droite

if glouton = 5 then gosub glouton

end

' 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=2 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_all
terminate


Dernière édition par Jicehel le Jeu 24 Nov 2011 - 1:26, édité 2 fois
Revenir en haut Aller en bas
Nardo26

Nardo26


Nombre de messages : 2294
Age : 55
Localisation : Valence
Date d'inscription : 02/07/2010

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyMer 23 Nov 2011 - 23:23

si ça peut te donner des idées...
c'est pas à jour par rapport à la derniere version que tu as posté...

Code:


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

DIM ang, d, dtn, espace, f, g, gd, glouton, h, i, j, k, n, pas, pasv, r, s, sd, v, pt, rot, w, c(4), mpt, mgd, clavier
LABEL affiche, droite, gauche, glouton, lab, moteur, pan1, pan2, pan4, pan8, pivot
LABEL r1, r2, r3, r4, r5, r6, r7, termine, trace
LABEL createNewObject
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_CUBE 4, 1 : 3D_HIDE 3 : 3D_HIDE 4 : ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA
3D_SPHERE 5, 1 : 3D_COLOR 5, 0, 96, 0 : ' CRÉATION DU GLOUTON VERT MANGEUR D'ORANGES
DIM debug : debug =0
IF Debug =1
    FORM 500 : WIDTH 500, 150 : HEIGHT 500, 200 : TOP 500, 3 : LEFT 500, 3
    ALPHA 501 : PARENT 501, 500 : HEIGHT 501, 15 : TOP 501, 3 : LEFT 501, 3
    ALPHA 502 : PARENT 502, 500 : HEIGHT 502, 15 : TOP 502, 20 : LEFT 502, 3
    ALPHA 503 : PARENT 503, 500 : HEIGHT 503, 15 : TOP 503, 37 : LEFT 503, 3
END_IF

' ******************************************************************************
' ************************ 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.5 : pasv=1.5 : glouton =0
DIM a(h+1, v+1), mur(h+1, v+1), trc(h+1, v+1), trn(h+1, v+1), gln(h, v)
GOSUB lab

' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3D_TEXT 6, "ENTRÉE" : 3D_COLOR 6, 0, 0, 255 : 3D_Y_ROTATE 6, 180
3D_POSITION 6, ((h/2)*8)-(2* ODD(h)-2* EVEN(h)), 4, 12
3D_TEXT 7, "SORTIE" : 3D_COLOR 7, 0, 0, 255 : 3D_Y_ROTATE 7, 180
3D_POSITION 7, ((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
        gln(i, j)=a(i, j)
        IF (j<>2 OR i<> INT(h/2)) AND (j<>v OR i<> INT(h/2))
            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
        END_IF

    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
f=i : g=j : sd=1 : ' f et g position départ du glouton vert, sd son sens de déplacement
3D_POSITION 5, ((h/2)*8)-(3* ODD(h)), 4, g*8
3D_POSITION 3, ((h/2)*8)-(3* ODD(h)), 4, j*8 : GOSUB affiche
TIMER 2 : TIMER_INTERVAL 2, 300 : ON_TIMER 2, moteur
TIMER 200 : TIMER_INTERVAL 200, 1000 : ON_TIMER 200, glouton
END


' ******************************************************************************
' *****************    LE PROGRAMME PRINCIPAL    ******************************
' ******************************************************************************
moteur:
    TIMER_OFF 2

    IF debug =1
        CAPTION 501, "f=" + STR$(f)+"; g=" + STR$(g)+"; sd=" + STR$(sd)
    END_IF

    IF espace=1 THEN GOSUB trace
    clavier= SCANCODE
    SELECT clavier
        CASE 27 : GOTO termine : ' SORTIE PROGRAMME
        CASE 32 : espace=1 : ' AFFICHAGE DU PLAN DU LABYRINTHE
        CASE 37 : TIMER_OFF 200 : GOSUB gauche : TIMER_ON 200 : ' FLECHE GAUCHE = ROTATION A GAUCHE
        CASE 39 : TIMER_OFF 200 : GOSUB droite : TIMER_ON 200 : ' FLECHE DROITE = ROTATION A DROITE
        CASE 38 : ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
        SELECT dtn
            CASE 1
            IF j <v+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
            CASE 2
            IF i <h AND j >1
                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
            CASE 3
            IF j >2
                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
            CASE 4
            IF i >2 AND j >1
                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
    END_SELECT
    IF clavier<>0
        3D_POSITION 3, i*8, 4, j*8
    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 PAR DES SPHÈRES ORANGES
    IF trc(i, j)=0
        GOSUB createNewObject

        3D_SPHERE createNewObject_id, 0.25
        3D_POSITION createNewObject_id, i*8, 1, j*8
        3D_COLOR createNewObject_id, 224, 128, 32
        trc(i, j)=createNewObject_id : trn(i, j)= createNewObject_id
    END_IF

        IF debug =1
            CAPTION 503, "trc(i,j)=" + STR$(trc(i, j))
        END_IF

    TIMER_ON 2
RETURN
' ******************************************************************************
' ******************************************************************************

' Gestion déplacement du glouton vert (le monstre) qui mange vos oranges
glouton:
    TIMER_OFF 200
    SELECT sd
        CASE 1
        mpt=g*8 : g=g+1 : mgd=g*8
        REPEAT
            mpt=mpt+pas : 3D_POSITION 5, f*8, 4, mpt
        UNTIL mpt>=mgd
        IF gln(f, g)=2 OR gln(f, g)=4 OR gln(f, g)=6 OR gln(f, g)=10 OR gln(f, g)=14 THEN sd=2
        IF gln(f, g)=3 THEN sd=4
        IF gln(f, g)=7 THEN sd=3
        IF debug =1
            CAPTION 502, "gln(f,g+1)=" + STR$(gln(f, g))+"; sd=" + STR$(sd)
        END_IF
        CASE 2
        mgd=f*8 : f=f-1 : mpt=f*8
        REPEAT
            mgd=mgd-pas : 3D_POSITION 5, mgd, 4, g*8
        UNTIL mgd<=mpt
        IF gln(f, g)=1 OR gln(f, g)=2 OR gln(f, g)=3 THEN sd=3
        IF gln(f, g)=9 THEN sd=1
        IF gln(f, g)=11 THEN sd=4
        IF debug =1
            CAPTION 502, "gln(f-1,g)=" + STR$(gln(f, g))+"; sd=" + STR$(sd)
        END_IF

        CASE 3
        mgd=g*8 : g=g-1 : mpt=g*8
        REPEAT
            mgd=mgd-pas : : 3D_POSITION 5, f*8, 4, mgd
        UNTIL mgd<=mpt
        IF gln(f, g)=1 OR gln(f, g)=8 OR gln(f, g)=9 THEN sd=4
        IF gln(f, g)=12 THEN sd=2
        IF gln(f, g)=13 THEN sd=1
        IF debug =1
            CAPTION 502, "gln(f,g-1)=" + STR$(gln(f, g))+"; sd=" + STR$(sd)
        END_IF

        CASE 4
        mpt=f*8 : f=f+1 : mgd=f*8
        REPEAT
            mpt=mpt+pas : 3D_POSITION 5, mpt, 4, g*8
        UNTIL mpt>=mgd
        IF gln(f, g)=4 OR gln(f, g)=8 OR gln(f, g)=12 THEN sd=1
        IF gln(f, g)=6 THEN sd=3
        IF gln(f, g)=14 THEN sd=2
        IF debug =1
            CAPTION 502, "gln(f+1,g)=" + STR$(gln(f, g))+"; sd=" + STR$(sd)
        END_IF

    END_SELECT
    glouton =0
    if trc(f,g)<>0
      3D_DELETE trc(f,g)
      trc(f,g)=0
    end_if
    TIMER_ON 200
    ' TIMER_ON 2
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
    REPEAT
        clavier = SCANCODE
        SELECT clavier
            CASE 27 : GOTO termine
            CASE 37 : GOSUB gauche
            CASE 39 : GOSUB droite
        END_SELECT
        CAM_POSITION O3D_X_POSITION(3), w, O3D_Z_POSITION(3)
        DISPLAY:GOSUB glouton:wait 700
    UNTIL clavier=32
    REPEAT
        w=w-pasv : CAM_POSITION O3D_X_POSITION(3), w, O3D_Z_POSITION(3) : DISPLAY
    UNTIL w=4
    espace=0
RETURN

' 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=2 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_ALL
TERMINATE

createNewObject:
    IF VARIABLE("createNewObject_id")=0
        DIM createNewObject_id
    END_IF
    createNewObject_id=1
    WHILE O3D_OBJECT_EXISTS(createNewObject_id)=1
        createNewObject_id=createNewObject_id+1
    END_WHILE
RETURN

EDIT : J'ai modifié le code, il tiens compte de tes dernieres modifs...
PS2: Le glouton, ne gloutonne rien du tout... c'est normal ? Wink


Ca à l'air de fonctionner (en dehors du glouton). Il manque plus que la touche finale de jjn4 lorsque l'on arrive à la sortie et cela sera OK! Wink

EDIT2 : Déplacement du glouton lors de la vue en altitude...
EDIT3 : Le glouton, gloutonne.... Wink
EDIT4 : Pour rajouter du piquant,
- on peut mettre en place un score qui s'incremente à chaque sphère posée et qui décrémente si le glouton en mange une... si le score=0 à cause du glouton -> Game-over
- on peut autoriser le glouton à aller jusqu'à la sortie, si il l'atteint avant le joueur -> game over



Revenir en haut Aller en bas
http://nardo26.lescigales.org
Jicehel

Jicehel


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

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyJeu 24 Nov 2011 - 1:27

On s'est croisé Nardo, je regarde ton source Smile J'ai édité le mien dans le post au dessus du tien.

Le tien marche bien 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 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyJeu 24 Nov 2011 - 11:05

BONJOUR AMIS PANORAMICIENS,

Hier soir, avant de me coucher, j'ai pu lire le message de cosmos, et bien que je n'étais pas convaincu, j'ai décidé de stopper le timer au début de la procédure moteur et de le remettre en route juste avant le return, et là, miracle, plus de plantage.
Mais je ne suis pas convaincu, pourquoi? parce que j'ai fait d'autres programmes avant de me lancer dans ce labyrinthe, où je déplace des objets dans un timer on, et jamais de plantage. Il faut dire que j'utilise dans ces programmes des "3d_mesh", avec mon véhicule moteur et mon véhicule caméra.
Alors? Peut-être est ce du au nombre total d'objets, car dans ce labyrinthe, rien que les murs représentent environ 600 objets 3d et on y rajoute des spheres (les oranges).
Bref, ce matin en me levant, j'ai vu les prog corrigés de Jicehel et de Nardo que je remercie chaleureusement, et où j'ai pu constater qu'ils ont utiliser le timer_off. Donc Cosmos avait raison, j'ai bien fait une erreur de structure dans mon prog. Vous vous programmez certainement depuis plus longtemps que moi et connaissez sans doute d'autre langage comme le C ou le VBA ou autre. Moi je ne connais que le panoramic pour le moment et je le découvre. Les DLL c'est encore abstrait pour moi, mais j'espère arriver un jour à comprendre. Comme les include, execute et chain sont des instructions qui ont l'air très puissante mais que j'ai du mal à cerner.
Ceci dit, voilà mon dernier code pour le labyrinthe 3d qui tient compte d'une partie de Jicehel et d'une partie de Nardo. Mettre le glouton dans un second timer, ça me ralentit trop les déplacements qui se font par à coup. J'ai préféré garder la variable glouton=glouton+1 avec quand =5 déplacement du glouton, ce qui à mon sens lui correspond mieux, car cherchant une orange à glouglouter dans chaque case.
Code:

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

dim c_gauche,c_droite,c_avant
dim ang,d,dtn,espace,f,g,gd,glouton,h,i,j,k,n,pas,pasv,r,s,sd,v,pt,rot,w, c(4),mpt,mgd
label affiche,droite,gauche,glouton,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_cube 4,1:3d_hide 3:3d_hide 4: ' CRÉATION DES VÉHICULES MOTEUR ET CAMÉRA
3d_sphere 5,1:3d_color 5,0,96,0:' CRÉATION DU GLOUTON VERT MANGEUR D'ORANGES


' ******************************************************************************
' ************************ 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:c_gauche=0:c_droite=0:c_avant=0
pas=0.25:pasv=1:glouton=0
dim a(h+1,v+1),mur(h+1,v+1),trc(h,v),trn(h,v),gln(h,v),vrobj
gosub lab

' ******************************************************************************
' ******************************************************************************



' ******************************************************************************
' ****************      CONSTRUCTION DU LABYRINTHE      ************************
' ******************************************************************************
3d_text 6,"ENTRÉE":3d_color 6,0,0,255:3d_y_rotate 6,180
3d_position 6,((h/2)*8)-(2*odd(h)-2*even(h)),4,12
3d_text 7,"SORTIE":3d_color 7,0,0,255:3d_y_rotate 7,180
3d_position 7,((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
  gln(i,j)=a(i,j):trc(i,j)=0:trn(i,j)=0
  if (j<>2 or i<> int(h/2)) and (j<>v or i<> int(h/2))
    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
  end_if
  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:vrobj=number_3d_objects
f=i:g=j:sd=1:' f et g position départ du glouton vert, sd son sens de déplacement
3d_position 5,((h/2)*8)-(3*odd(h)),4,g*8
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:
timer_off 2
if espace=1 then goto trace
if c_gauche=1 then gosub gauche
if c_droite=1 then gosub droite
if c_avant=1
    if dtn=1 and j < v+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 and i < h  and j > 1
        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 and j > 2
        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 and i > 2 and j > 1
        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
    c_avant=0
end_if

select scancode
case 27:goto termine: ' SORTIE PROGRAMME
case 32:espace=1: ' AFFICHAGE DU PLAN DU LABYRINTHE
case 37:c_gauche=1: ' FLECHE GAUCHE = ROTATION A GAUCHE
case 39:c_droite=1: ' FLECHE DROITE = ROTATION A DROITE
case 38:c_avant=1: ' FLECHE HAUT = DTN DEFINIT LA DIRECTION NORD, OUEST, SUD OU EST
end_select

3d_position 3, i*8,4,j*8

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

glouton=glouton+1:if glouton=5 then gosub glouton

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

if trc(i,j)=0 and trn(i,j)<>0
  3d_sphere trn(i,j),0.25
  3d_position trn(i,j),i*8,1,j*8
  3d_color trn(i,j),224,128,32
  trc(i,j)=trn(i,j)
end_if

timer_on 2
return



' ******************************************************************************
' ******************************************************************************

' Gestion déplacement du glouton vert (le monstre) qui mange vos oranges
glouton:
select sd

  case 1
    mpt=g*8:g=g+1:mgd=g*8
    repeat
        mpt=mpt+pas:3d_position 5,f*8,4,mpt
    until mpt>=mgd
  if gln(f,g)= 2 or gln(f,g)=4 or gln(f,g)=6 or gln(f,g)=10 then sd=2
  if gln(f,g)= 3 then sd=4
  if gln(f,g)= 7 then sd=3

  case 2
    mgd=f*8:f=f-1:mpt=f*8
    repeat
        mgd=mgd-pas:3d_position 5,mgd,4,g*8
    until mgd<=mpt
  if gln(f,g)= 1 or gln(f,g)=2 or gln(f,g)=3 then sd=3
  if gln(f,g)= 9 then sd=1
  if gln(f,g)=11 then sd=4

  case 3
    mgd=g*8:g=g-1:mpt=g*8
    repeat
        mgd=mgd-pas::3d_position 5,f*8,4,mgd
    until mgd<=mpt
  if gln(f,g)= 1 or gln(f,g)=8 or gln(f,g)=9 then sd=4
  if gln(f,g)=12 then sd=2
  if gln(f,g)=13 then sd=1

  case 4
    mpt=f*8:f=f+1:mgd=f*8
    repeat
        mpt=mpt+pas:3d_position 5,mpt,4,g*8
    until mpt>=mgd
  if gln(f,g)= 4 or gln(f,g)=8 or gln(f,g)=12 then sd=1
  if gln(f,g)= 6 then sd=3
  if gln(f,g)=14 then sd=2

end_select

if trc(f,g)<>0 then 3d_delete trc(f,g):trc(f,g)=0

glouton=0
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

repeat
if scancode=27 then goto termine
if scancode=37 then gosub gauche
if scancode=39 then gosub droite
glouton=glouton+1:if glouton=4 then gosub glouton
wait 100
until scancode=32

  repeat
      w=w-pasv:cam_position o3d_x_position(3),w,o3d_z_position(3):display
  until w=4
  espace=0
  goto moteur


' 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
    c_gauche=0
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
    c_droite=0
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

Je pense que je vais laisser maintenant ce sujet du labyrinthe de coté, car je pense que vous avez tout les éléments principaux pour finir le programme.
Comme disait Nardo, on peut rajouter un score qui s'incrémente si on plante une orange ou qui se décrémente si le glouton la mange. etc...
Ça, c'est à chacun de fignoler le programme comme il l'entend et j'ai vu que le sujet interresse pas mal de monde. Moi ce que je voulais au départ c'est donner quelques exemples de programmation en 3d avec ce prog, car il n'y en a pas beaucoup sur le forum et il faut les chercher.

A bientôt. Wink
Revenir en haut Aller en bas
Jicehel

Jicehel


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

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyJeu 24 Nov 2011 - 11:24

Merci bignono, grace à toi, on a avancé sur un cas concret de jeu en 3D et ça va sans doute donner beaucoup d'idées Smile (qui seront developpées dans leur propres sujet même si ce sont des dérivés de ton programme)
Revenir en haut Aller en bas
Invité
Invité




Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyJeu 24 Nov 2011 - 12:45

La raison pour ma part de dire qu'il y avait un problème de structure, est en dehors du fait que le programme s’arrêtait sur un return, qu'en mode teste de mon éditeur de fortune, en l’arrêtant par mes moyens d’arrêter une boucle, j'avais des plantage successifs de windows par le timer. Ceci ne se produit par mon bouton que dans ce cas là.
Ensuite normalement pour être en mode évènement en Panoramic, il faut obligatoirement un clic. Le timer dans le lancement du programme avant le END a normalement pour fonction de simuler le clic. C'est le seul moyen de lancer le programme, en dehors du clic sur un objet en mode évènement. Donc il faut l’arrêter, et jouer ensuite avec les touches dans ce programme.
Ça c'est moi qui le dis, à défaut de ne pas avoir l'avis de Jack. Mais apparemment, comme je l'ai constaté ailleurs, je crois être dans le vrai.
Cela dit, je suis dans mon programme, et j'ai pas réessayé les dernières mises à jour depuis.
Revenir en haut Aller en bas
Nardo26

Nardo26


Nombre de messages : 2294
Age : 55
Localisation : Valence
Date d'inscription : 02/07/2010

Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 EmptyJeu 24 Nov 2011 - 13:10

Je vais plus loin que Cosmos: il y a toujours un problème de structure...
cela ne me plais pas de devoir faire un goto termine dans une procédure évènementielle... c'est un peu brutal comme solution...

Revenir en haut Aller en bas
http://nardo26.lescigales.org
Contenu sponsorisé





Labyrinth - Page 4 Empty
MessageSujet: Re: Labyrinth   Labyrinth - Page 4 Empty

Revenir en haut Aller en bas
 
Labyrinth
Revenir en haut 
Page 4 sur 4Aller à la page : Précédent  1, 2, 3, 4
 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: