Zurück   Flashforum > Flash > ActionScript > Softwarearchitektur und Entwurfsmuster

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 22-03-2003, 15:07   #1 (permalink)
Neuer User
 
Benutzerbild von Pingu
 
Registriert seit: Nov 2001
Beiträge: 2.089
auch von mir mal wieder was :)

so..weil ich so lange hier nicht mehr beigetragen hab' *g* , habe ich auch mal ein kleines Spielchen gemacht. Sollte bekannt sein^^

ActionScript:
  1. //init
  2. _root.depth = 0
  3. _root.clickcnt=0
  4. //var object
  5. _root.data={}
  6. _root.data.stab_n=3
  7. _root.data.stab_dist=100
  8. _root.data.stab_w=10
  9. _root.data.stab_h=100
  10. _root.data.sch_w=100
  11. _root.data.sch_h=10
  12. _root.data.sch_dellung=7
  13. _root.data.sch_ydist=5
  14. //end var object
  15. //some functions
  16.     MovieClip.prototype.getx=function(w,wo){
  17.        
  18.         return (_root["stab"+w]._x - wo._width/2 + _root["stab"+w]._width/2 )
  19.         }
  20.             MovieClip.prototype.gety=function(w,wo){
  21.         return (_root["stab"+w]._y + _root["stab"+w]._height -wo._height- _root["sch_array"+w].length*(_root.data.sch_h+_root.data.sch_ydist))
  22.         }
  23.        
  24. //anfangsmatrix
  25. _root.mat=[1,1,1,1,1,1
  26. //creation
  27.         createTextField("cligg",_root.depth++,50,200,80,2)
  28.         _root.cligg.autoSize="center"
  29.         tf=new TextFormat()
  30.         tf.font="verdana"
  31.         tf.bold=1
  32.         _root.cligg.size=16
  33.         _root.cligg.setNewTextFormat(tf)
  34.     var z = 1
  35.     while(z<=_root.data.stab_n){
  36.         _root.createEmptyMovieClip("stab"+z,_root.depth++)
  37.         with(_root["stab"+z]){
  38.             lineStyle(1,0x000000)
  39.             beginFill(0x000000,100)
  40.             moveTo(0,0)
  41.             lineTo(0,_root.data.stab_h)
  42.             lineTo(_root.data.stab_w,_root.data.stab_h)
  43.             lineTo(_root.data.stab_w,0)
  44.             lineTo(0,0)
  45.             endFill()
  46.             _x=50+(_root.data.stab_dist+_width)*z
  47.            
  48.         }
  49.         z++
  50.     }
  51. //end creation
  52.    
  53.     //scheiben
  54.     var z = 1
  55.     while(z<=_root.data.stab_n){
  56.         _root["sch_array"+z]=[]
  57.         z++
  58.         }
  59.         z = 0
  60.     while(z<_root.mat.length){
  61.         _root.createEmptyMovieClip("sch"+z,_root.depth++)
  62.        
  63.         _root["sch"+z].onPress=function(){
  64.             _root.clickcnt++
  65.             if(_root["sch_array"+this.row][_root["sch_array"+this.row].length-1]==this.i){
  66.                 this.ox=this._x
  67.                 this.oy=this._y
  68.                 startDrag(this)
  69.                 }
  70.             }
  71.             _root["sch"+z].onRelease=function(){
  72.                
  73.                 var row = this.row
  74.                 this.stopDrag()
  75.                 //getrow
  76.                 var z = 0
  77.                 while(z<=_root.data.stab_n){
  78.                     if(this.hitTest(_root["stab"+z])){
  79.                         var rown=z
  80.                         break;
  81.                         }
  82.                 z++
  83.                 }
  84.                 //end get row
  85.                 if(rown==row || ((rown != row) && (_root["sch"+_root["sch_array"+rown][_root["sch_array"+rown].length-1]]._width<this._width)  && _root["sch_array"+rown].length>0)|| rown==undefined){
  86.                     this._x=this.ox
  87.                     this._y=this.oy
  88.                     return "h"
  89.                    
  90.                 }else{
  91.                     this._x=getx(rown,this)
  92.                     this._y=gety(rown,this)
  93.                     this.row=rown
  94.                     _root["sch_array"+row].pop()
  95.                     _root["sch_array"+rown].push(this.i)
  96.                     }
  97.                     delete this.ox
  98.                     delete this.oy
  99.                 }
  100.         with(_root["sch"+z]){
  101.             lineStyle(1,0x000000)
  102.             beginFill(0x22ff77,100)
  103.             moveTo(0,0)
  104.             lineTo(0,_root.data.sch_h)
  105.             lineTo(_root.data.sch_w,_root.data.sch_h)
  106.             lineTo(_root.data.sch_w,0)
  107.             lineTo(0,0)
  108.             endFill()
  109.             var w = _root.mat[z]
  110.             _width-=2*z*_root.data.sch_dellung
  111.             _x=getx(w,_root["sch"+z])
  112.             _y=gety(w,_root["sch"+z])
  113.             _root["sch_array"+w].push(z)
  114.             }
  115.             _root["sch"+z].i=z
  116.             _root["sch"+z].row=w
  117.         z++
  118.         }
  119.         delete _root.w
  120.         delete _root.z
  121.        
  122.         //check auf winning
  123.         win = function(){
  124.             var z = 1
  125.             while(z<_root.data.stab_n){
  126.                 if(_root["sch_array"+z].length>0) return false
  127.                 z++
  128.                 }
  129.                 _root.cligg.text="gewonnen"
  130.                 clearInterval(_root.checkk)
  131.                 clearInterval(_root.cl)
  132.         }
  133.         _root.checkk=setInterval(win,1000)
  134.        
  135.         clicker=function(){
  136.             _root.cligg.text="Clicks: "+_root.clickcnt
  137.             }
  138.             cl=setInterval(clicker,500)

hab's noch nich' auf Bugs überprüft *g*

falls jemand 'nen kommentar auf lage hat, is' immer schön
gruss
__________________

'n altes Game
neu entdeckt *g*
Reine
Pingu ist offline   Mit Zitat antworten
Alt 22-03-2003, 15:10   #2 (permalink)
Banned
 
Registriert seit: Jan 2002
Beiträge: 4.777
dat is ja cool und bock schwer
bw greets


btw: kennst du noch diesen maus-speed thread?
the-ox ist offline   Mit Zitat antworten
Alt 22-03-2003, 16:04   #3 (permalink)
nky
Bontempi Punk
 
Benutzerbild von nky
 
Registriert seit: Dec 2001
Ort: Dtld/Pfalz
Beiträge: 4.185
Ich versteh leider nur Bahnhof - ich hab mir das jetzt einfach mal so zurechtgelegt - das man den linken haufen - zum rechten haufen bringeb muss - wobei das teil imm pyramidenförmig bleiben muss ???
Leider kenn ich das Spiel net ..


Gruss nky
nky ist offline   Mit Zitat antworten
Alt 22-03-2003, 16:07   #4 (permalink)
Neuer User
 
Benutzerbild von Pingu
 
Registriert seit: Nov 2001
Beiträge: 2.089
kennst nich' ?

naja..namen weiss ich nich..aber das gibt's..hatte ich als kleines Kind :-)

das hat mich wohl geprägt.^^

Aber hast es genau richtig erkannt.

gruss
__________________

'n altes Game
neu entdeckt *g*
Reine
Pingu ist offline   Mit Zitat antworten
Alt 22-03-2003, 16:19   #5 (permalink)
ohnitsch
 
Registriert seit: Oct 2002
Ort: Wien
Beiträge: 42
wer das game nicht kennt hat ne bildungslücke

btw kleiner bug, er zählt jeden klick, nicht jeden zug
Klesk ist offline   Mit Zitat antworten
Alt 22-03-2003, 17:02   #6 (permalink)
Neuer User
 
Benutzerbild von Pingu
 
Registriert seit: Nov 2001
Beiträge: 2.089
jo..war so geplant *g*

aber kann man ja ändern

gruss
__________________

'n altes Game
neu entdeckt *g*
Reine
Pingu ist offline   Mit Zitat antworten
Alt 22-03-2003, 17:07   #7 (permalink)
Neuer User
 
Benutzerbild von :: RK ::
 
Registriert seit: Jan 2002
Ort: Umgebung Stuttgart
Beiträge: 5.412
hi,

cool gemacht,

wie soll man das denn bitte lösen, hab echt kein plan von.
macht für mich null sin. ???
__________________
Das Glück im Leben hängt von den guten Gedanken ab, die man hat.

Easing_Equations / Flash Kontaktformular / FlashPlugin W3C konform / Nützliche Beiträge zu FAQs
:: RK :: ist gerade online   Mit Zitat antworten
Alt 22-03-2003, 17:15   #8 (permalink)
Neuer User
 
Benutzerbild von v0id
 
Registriert seit: Oct 2002
Ort: München
Beiträge: 1.582
hab das spiel auch noch nicht gekannt
aber jetzt hab ichs raus
v0id ist offline   Mit Zitat antworten
Alt 22-03-2003, 17:21   #9 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Ort: Aachen
Beiträge: 1.081
Türme von Hanoi.


72 Klick. hab mich am Ende ein bissel verwurchtelt.
mehr infos zb. hier :
http://www.cut-the-knot.com/recurrence/hanoi.shtml
__________________
G.M. | working @ source lounge
georgexp ist offline   Mit Zitat antworten
Alt 22-03-2003, 18:09   #10 (permalink)
nky
Bontempi Punk
 
Benutzerbild von nky
 
Registriert seit: Dec 2001
Ort: Dtld/Pfalz
Beiträge: 4.185
NICE! Macht voll Spass - irgendwie kommen die Balkenspiele wieder in Mode..

Gruss nky
nky ist offline   Mit Zitat antworten
Alt 22-03-2003, 18:21   #11 (permalink)
Neuer User
 
Benutzerbild von Pingu
 
Registriert seit: Nov 2001
Beiträge: 2.089
das freut mich, dass es gefällt

wenn langeweile manchmal fruchtbare früchte trägt (oder so ähnlich)

gruss
__________________

'n altes Game
neu entdeckt *g*
Reine
Pingu ist offline   Mit Zitat antworten
Alt 22-03-2003, 18:24   #12 (permalink)
Achim Math.PI
 
Benutzerbild von bloba
 
Registriert seit: Jul 2001
Ort: cool Colonia
Beiträge: 11.642
Thumbs up

hut ab saugeil
__________________
gruß bloba

2 x onkel² b_d
bloba ist offline   Mit Zitat antworten
Alt 23-03-2003, 08:48   #13 (permalink)
Hirnverbrannt
 
Benutzerbild von NastyFrog
 
Registriert seit: Aug 2001
Ort: AUSTRIA
Beiträge: 2.020
105 Züge, is das viel. Schon oder?
Geiles Spiel.
__________________
50 Seiten hardcore ActionScript von den Grundlagen bis zu 3D Darstellungen.... eben eine Abendlektüre.

Dogs fucked the Pope, no fault of mine. Watch out! ... Why money? My name is Brinks; I was born ... born? Get sheep over side ... women and children to armored car ... orders from Captain Zeep.(Hunter S. Thompson)
NastyFrog ist offline   Mit Zitat antworten
Alt 23-03-2003, 09:15   #14 (permalink)
Herr Brot
 
Benutzerbild von mati
 
Registriert seit: Dec 2002
Beiträge: 1.692
hi! echt cool pingu!

63 züge *freu* absolutes minimum, denn das berechnet sich so:

2^n-1
sprich: 2^6(ringe) = 64; 64-1 = 63...
hab das mal ziemlich intensiv auf papier gemacht, mittlerweile schaffe ich es mit neun ringen und dem absoluten minimum, also 511 zügen. da wird man aber ziemlich bedusselt...

greetz, mati
__________________
„Ich war geheilt, all right!“
mati ist offline   Mit Zitat antworten
Alt 24-03-2003, 09:57   #15 (permalink)
the listener
 
Benutzerbild von NewBit
 
Registriert seit: Aug 2001
Ort: Halle (Saale)
Beiträge: 307
...man könnt noch level einführen - je weiter man kommt desto mehr ringe muß man umsortieren :-)

...he he he und dann gibt dat so richtig knoten im hirn

coole sache !

cu NewBit
NewBit ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 12:55 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele