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

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 22-06-2002, 23:12   #1 (permalink)
Krautammi oder Ammikraut?
 
Registriert seit: Dec 2001
Ort: Richmond, in Michigan, in den Stahtn
Beiträge: 1.604
Post Krautammi OOP 3D Spiel

Hey,
es ist wieder Zeit fuer ne Inspiration von mir! Vielleicht erinnern sich noch welche an meinen "Krautammi 3D Spectrum Analyzer", wo ich die prototype function "newRow" benutzt habe, um Reihen von 3d-Bloecken mit AS zu machen und positionieren. Sofort nach dem ich den Prototype 'erfunden' habe, wollte ich sofort ein Spiel daraus machen. Nach ca. 2 Wochen und den meisten Syntax den ich je geschrieben habe, hab ichs endlich geschafft. Und hier isses.
Das Prinzip: Man muss den Ball ueber die Reihen von Bloecken bewegen und die "Atome" einsammeln. Das Problem: Die Bloecke poppen mit Zeitabstaende (je nach Level) hoch. Sobald ein Block hochgepoppt ist, kann man an diesem nicht mehr vorbei kommen. Je mehr Zeit vergeht, desto mehr Bloecke sind hoeher, und das Spiel wirkt wie ein Labyrinth. Wenn der Ball ueber einem hochpoppendem Block ist, wird der Ball weggeschleudert und man hat verloren. Wenn ein Atom ueber einen hochpoppendem Block ist, wird das Atom zerstoert. Ihr koennt euch sicher vorstellen wie schwer das war, das alles zu programmieren.
Es ist sehr viel Syntax da, aber ich werde euch mal das Script geben, welches realisiert dass man an hohen Bloecken nicht vorbei kommt, usw.
ActionScript:
  1. MovieClip.prototype.moveVert = function(nummer) { //Vertikal Bewegen
  2.     for (i=0; i<=87; i++) {
  3.         if (this._y == this.blocksy[i]) {
  4.             if (this._x == this.blocksx[i]) {
  5.                 if (_root["block"+(i+nummer)]._y-213 == this.blocksy[i+nummer]) {
  6.                     return true;
  7.                     break;
  8.                 }
  9.             }
  10.         }
  11.     }
  12. };
  13. MovieClip.prototype.moveHori=function(arraynummer, nummer){ //Horizontal Bewegen
  14.     for (i=0; i<this.positionsy.length; i++) {
  15.             if (this._y == this.positionsy[i]) {
  16.                 if (this._x != this.positionsx[i][arraynummer]) {
  17.                     for (i=0; i<=87; i++) {
  18.                         if (this._y == this.blocksy[i]) {
  19.                             if (this._x == this.blocksx[i]) {
  20.                                 if (_root["block"+(i+nummer)]._y-213 == this.blocksy[i+nummer]) {
  21.                                     return true;
  22.                                     break;
  23.                                 }
  24.                             }
  25.                         }
  26.                     }
  27.                 }
  28.             }
  29.         }
  30. };
  31. //Control
  32. if (Key.isDown(Key.UP)) {
  33.             if (this._y>37) {
  34.                 if (this.moveVert(-11)) {
  35.                     this._x += 11;
  36.                     this._y -= 7;
  37.                 }
  38.             }
  39.         }
  40.         if (Key.isDown(Key.DOWN)) {
  41.             if (this._y<86) {
  42.                 if (this.moveVert(11)) {
  43.                     this._x -= 11;
  44.                     this._y += 7;
  45.                 }
  46.             }
  47.         }
  48.         if (Key.isDown(Key.RIGHT)) {
  49.             if (this.moveHori(1, 1)) {
  50.                 this._x += 35;
  51.             }
  52.         }
  53.         if (Key.isDown(Key.LEFT)) {
  54.             if (this.moveHori(0, -1)) {
  55.                 this._x -= 35;
  56.             }
  57.         }
  58.  
  59. //newRow prototype und AS fuer die Bloecke:
  60.  
  61. _root.createEmptyMovieClip("block0", 0);
  62. with (_root.block0) {
  63.     lineStyle(1, 0xFFFFFF, 100);
  64.     beginFill(0x0000CC, 70);
  65.     moveTo(0, 0);
  66.     lineTo(20, 0);
  67.     lineTo(20, -200);
  68.     lineTo(0, -200);
  69.     lineTo(0, 0);
  70.     endFill();
  71.     beginFill(0x0000FF, 70);
  72.     moveTo(0, -200);
  73.     lineTo(10, -205);
  74.     lineTo(30, -205);
  75.     lineTo(20, -200);
  76.     endFill();
  77.     beginFill(0x000066, 70);
  78.     moveTo(30, -205);
  79.     lineTo(30, -5);
  80.     lineTo(20, 0);
  81.     lineTo(20, -200);
  82.     endFill();
  83. }
  84. _root.block0._x = 150;
  85. _root.block0._y = 250;
  86. for (i=1; i<=87; i++) {
  87.     _root.block0.duplicateMovieClip("block"+i, i);
  88. }
  89. _root.block0.swapDepths(0);
  90. for (i=1; i<=10; i++) {
  91.     _root["block"+i]._x = _root["block"+(i-1)]._x+35;
  92.     _root["block"+i]._y = _root["block"+(i-1)]._y;
  93.     _root["block"+i].swapDepths(0);
  94. }
  95. MovieClip.prototype.newRow = function(basemc, alignmc, init, kond, depth) {
  96.     _root[basemc]._x = _root[alignmc]._x-11;
  97.     _root[basemc]._y = _root[alignmc]._y+7;
  98.     _root[basemc].swapDepths(depth);
  99.     for (i=init; i<=kond; i++) {
  100.         _root["block"+i]._x = _root["block"+(i-1)]._x+35;
  101.         _root["block"+i]._y = _root["block"+(i-1)]._y;
  102.         _root["block"+i].swapDepths(5*i+depth);
  103.     }
  104. };
  105. _root.newRow("block11", "block0", 12, 21, 2);
  106. _root.newRow("block22", "block11", 23, 32, 4);
  107. _root.newRow("block33", "block22", 34, 43, 6);
  108. _root.newRow("block44", "block33", 45, 54, 8);
  109. _root.newRow("block55", "block44", 56, 65, 10);
  110. _root.newRow("block66", "block55", 67, 76, 12);
  111. _root.newRow("block77", "block66", 78, 87, 14);
Dann waren noch ewige Depth-Problem da. z.B. Wenn man hinter einem Block steht, darf man ja den Ball nicht sehen. Dann habe ich einen roten Pfeil hin, dass man weiss wo der Ball ist.
Es sind leider noch ein paar swapDepth bugs drin, die ich einfach nicht rauskrieg.

Obwohl ich nicht den ganzen Syntax gepostet habe, weil es einfach zu viel ist, will ich trotzdem dass das Spiel als OOP und 3D Inspiration zaehlt. Die Fla kommt auch bald, dann kann man den ganzen Syntax betrachen.

Ich hoffe ihr habt Spass dran!

Angucken

PS: Ich bin erst bis Level 4 gekommen. Wie weit schafft ihr es?
__________________
Krautammi... (zur Zeit mal da, mal nicht)

In dehn Stahtn
-------------------------------------
Flash- It's not a program, it's a state of mind.
Krautammi 2 , Meine Site: Flas, Tuts, Erklaerungen, und anderes.

Site Update!
Atom Hunter: OOP 3D Spiel!!!


Geändert von krautammi (22-06-2002 um 23:16 Uhr)
krautammi ist offline   Mit Zitat antworten
Alt 22-06-2002, 23:13   #2 (permalink)
Banned
 
Registriert seit: Jan 2002
Beiträge: 4.777
Thumbs up

schicke sache
the-ox ist offline   Mit Zitat antworten
Alt 22-06-2002, 23:26   #3 (permalink)
meistens harmlos
 
Benutzerbild von rena
 
Registriert seit: Jun 2001
Ort: Stuttgart
Beiträge: 17.643
Thumbs up

respekt ... feines teil

gruß
rena
__________________
www.rena-hermann.de

The angels have the phone box
rena ist offline   Mit Zitat antworten
Alt 23-06-2002, 02:27   #4 (permalink)
Überzeugter Flasher...
 
Benutzerbild von DoppelX
 
Registriert seit: Oct 2001
Ort: Köln
Beiträge: 1.654
also krautammi ... RESPEKT!!
__________________
Tjo...
DoppelX ist offline   Mit Zitat antworten
Alt 23-06-2002, 10:47   #5 (permalink)
helpQLODhelp
 
Benutzerbild von bokel
 
Registriert seit: Feb 2002
Ort: Köln
Beiträge: 8.505
krautammi,
super spielidee.

auf meinem schlappen rechner
leider ein wenig hakelig.

mfg r.
bokel ist offline   Mit Zitat antworten
Alt 23-06-2002, 15:03   #6 (permalink)
Krautammi oder Ammikraut?
 
Registriert seit: Dec 2001
Ort: Richmond, in Michigan, in den Stahtn
Beiträge: 1.604
Vielen Dank an alle


@Ralf: Ja, bei mir ist es am Anfang wenn noch viele Atome da sind auch ein bisschen wackelig. Ist wegen den Tweens in den Atomen. Ich hab einen 700MHZ, und sobald nur noch 5 atome da sind, geht alles wieder einwandfrei.

@alle: Wie geht es mit euerm Rechner?
__________________
Krautammi... (zur Zeit mal da, mal nicht)

In dehn Stahtn
-------------------------------------
Flash- It's not a program, it's a state of mind.
Krautammi 2 , Meine Site: Flas, Tuts, Erklaerungen, und anderes.

Site Update!
Atom Hunter: OOP 3D Spiel!!!

krautammi ist offline   Mit Zitat antworten
Alt 23-06-2002, 18:10   #7 (permalink)
nky
Bontempi Punk
 
Benutzerbild von nky
 
Registriert seit: Dec 2001
Ort: Dtld/Pfalz
Beiträge: 4.185
sehr fett und geiler Sound
mfg nky
nky ist offline   Mit Zitat antworten
Alt 23-06-2002, 19:08   #8 (permalink)
Steffen G.
 
Benutzerbild von Tschdaeff
 
Registriert seit: Aug 2001
Ort: Ba-Wü
Beiträge: 4.123
jupp ganz schoön cool

also bei mir 1,7 ghz Athlon 256 DD-Ram läufts flüssig


cu mfg
Tschdaeff
__________________
mod@
www.flashbattle.de
www.steffen-guse.de
------------------------------------

Tschdaeff ist offline   Mit Zitat antworten
Alt 23-06-2002, 22:59   #9 (permalink)
Neuer User
 
Benutzerbild von Pingu
 
Registriert seit: Nov 2001
Beiträge: 2.089
fette sache..hab mit meinem 650 aber ein paar probs über level 4 zu kommen,weil die Kugel ruckelt

__________________

'n altes Game
neu entdeckt *g*
Reine
Pingu ist offline   Mit Zitat antworten
Alt 24-06-2002, 17:34   #10 (permalink)
Krautammi oder Ammikraut?
 
Registriert seit: Dec 2001
Ort: Richmond, in Michigan, in den Stahtn
Beiträge: 1.604
Nochmals Vielen Dank

@Pingu: Ja, haste Recht, sobald die Bloecke schneller hochpoppen, wird es ein bisschen kniffelig mit nem langsamen Rechner... aber hoffentlich ist es nicht zu schlimm
__________________
Krautammi... (zur Zeit mal da, mal nicht)

In dehn Stahtn
-------------------------------------
Flash- It's not a program, it's a state of mind.
Krautammi 2 , Meine Site: Flas, Tuts, Erklaerungen, und anderes.

Site Update!
Atom Hunter: OOP 3D Spiel!!!

krautammi ist offline   Mit Zitat antworten
Alt 25-06-2002, 16:21   #11 (permalink)
Krautammi oder Ammikraut?
 
Registriert seit: Dec 2001
Ort: Richmond, in Michigan, in den Stahtn
Beiträge: 1.604
So, die Fla ist jetzt auch im Internet.
Man kann sie auf meiner Site in der Fla Section runterladen!

Viel Spass damit!
__________________
Krautammi... (zur Zeit mal da, mal nicht)

In dehn Stahtn
-------------------------------------
Flash- It's not a program, it's a state of mind.
Krautammi 2 , Meine Site: Flas, Tuts, Erklaerungen, und anderes.

Site Update!
Atom Hunter: OOP 3D Spiel!!!

krautammi ist offline   Mit Zitat antworten
Alt 27-06-2002, 19:19   #12 (permalink)
Achim Math.PI
 
Benutzerbild von bloba
 
Registriert seit: Jul 2001
Ort: cool Colonia
Beiträge: 11.642
Thumbs up

wow cool
__________________
gruß bloba

2 x onkel² b_d
bloba ist offline   Mit Zitat antworten
Alt 01-07-2002, 15:30   #13 (permalink)
Der kleine Wilde
 
Benutzerbild von Zack McCracken
 
Registriert seit: Apr 2002
Ort: manchmal aufm Klo... ;-)
Beiträge: 123
Nette Sache!

Habe es aber auch nur bis Level4 geschafft.
Aber immerhin 4200 Punkte! *freu*

Greetz,
Zack
__________________
The next Dimension goes online at 15th of August 2002

Something 2 Mail?
Just klick here!
Zack McCracken ist offline   Mit Zitat antworten
Alt 12-07-2002, 21:50   #14 (permalink)
Steffen G.
 
Benutzerbild von Tschdaeff
 
Registriert seit: Aug 2001
Ort: Ba-Wü
Beiträge: 4.123
hab 4100, aber is schwer

cu mfg
Tschdaeff
__________________
mod@
www.flashbattle.de
www.steffen-guse.de
------------------------------------

Tschdaeff ist offline   Mit Zitat antworten
Alt 13-07-2002, 05:50   #15 (permalink)
Krautammi oder Ammikraut?
 
Registriert seit: Dec 2001
Ort: Richmond, in Michigan, in den Stahtn
Beiträge: 1.604
Muss doch eine Herausforderung sein, oder?
__________________
Krautammi... (zur Zeit mal da, mal nicht)

In dehn Stahtn
-------------------------------------
Flash- It's not a program, it's a state of mind.
Krautammi 2 , Meine Site: Flas, Tuts, Erklaerungen, und anderes.

Site Update!
Atom Hunter: OOP 3D Spiel!!!

krautammi 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 15:31 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele