Sachsenpaule
SENATOR BABYHEAD  Posts: 167 Registered: 11/16/2003 Offline
|
5/4/2005 at 15:39 |
Ok, so i got 5 coordinates which i want to adress with a movieclip,
random.
More easily:
there are 5 points, in each point should appear a target.
Like in this old fairmarkt game where you have to hit some beavers on the head with a wooden hammer.
here is my code, what do you think is wrong:
schiessen = false;
verpasst = 0;
ebene = 0;
koordinaten = new Array("62,240", "141,339", "243,193", "464,303", "564,245");
// iam adding my mouseclip (works)
_root.attachMovie("mc_maus", "mc_mausdrin", 32000);
mc_mausdrin.onEnterFrame = function () {
startDrag(this, true);
}
mc_mausdrin.onMouseDown = function () {
this.gotoAndPlay("schuss");
}
// random function
function Zufallsausgabe(zufallkoordinaten) {
var Zahl = Math.round(Math.random()*5)
if (Zahl > 0 && Zahl < 6) {
return( koordinaten[Zahl] );
}
else {
Zufallsausgabe();
}
}
// this splits the array one more time, becourse i have two values, one for x, and one for y
zufall = new Array ("zufallkoordinaten");
x = zufall[1];
y = zufall[2];
//create a target at random
erzeugeZiel = function(symbol, punkte) {
ebene++;
var erzeugtesZiel = _root.attachMovie(symbol, symbol + ebene, ebene);
// take the splitted array and use it for the coordinates
erzeugtesZiel._x = x;
erzeugtesZiel._y = y;
erzeugtesZiel.punkte = punkte;
erzeugtesZiel.onEnterFrame = Zielfunktion;
}
// this counts up some points
Zielfunktion = function() {
if((this.hitTest(mc_maus)) && (schiessen == true)){
this.gotoAndStop("getroffen");
score += this.punkte;
}
}
ZielIntervalDauer = 500;
ZielErzeugungszahl = 5;
// this shoul create the movie
ZielErzeugung = function(){
var ZielZufallszahl = random(20);
if(ZielZufallszahl = ZielErzeugungszahl){
erzeugeZiel("auge", 10);
}
}
ZielInterval = setInterval(Zielerzeugung, ZielIntervalDauer);
And better:
Do you have some better ideas to solve this problem better then splitting two arrays up?
[Edited on 4/5/2005 by Sachsenpaule]
____________________ I used to be an atheist, until I realized I had nothing to shout during blowjobs. "Oh Random Chance! Oh Random Chance!" just doesn't cut it….
Robert Anton Wilson, 1932 - 2007
|
| |
vasudeva
Bad Taste in your Mouth  SSHOLEPosts: 4618 Registered: 3/8/2002 Offline
|
5/4/2005 at 17:38 |
Like in this old fairmarkt game where you have to hit some beavers on the head with a wooden hammer.
That sentence received 100% of the applause this post generated in me.
____________________ slippedhole> I am on to you and your evil intentions. I am the true protector of this website and am willing to do battle with you. |
| |
mineralGod
SIR BABYHEAD  Posts: 87 Registered: 11/27/2003 Offline
|
5/4/2005 at 17:59 |
I'll take a look later if I get a chance, but I think you will find more help if you post your code and problem at Ultrashock
Create an account if you don't already have one and post your question /problem in the Flash/Actionscript forum.
I don't think you're going to get too much help here.
Theres lots of gay homos here.
____________________ "I don't want no cake..........I want me some PIE, ya dig what I'm sayin?" Boxy Brown |
| |
Sachsenpaule
SENATOR BABYHEAD  Posts: 167 Registered: 11/16/2003 Offline
|
5/4/2005 at 18:30  |
vasudeva: Like in this old fairmarkt game where you have to hit some beavers on the head with a wooden hammer.
That sentence received 100% of the applause this post generated in me.
In this case, this thread fulfilled its purpose.
Thanks resourcegod, for the link,
and ++
mineralGod
Theres lots of gay homos here.
I dont think so, they can be really, really straight, in some cases,
if nobody looks..
You know, genious and insanity.
____________________ I used to be an atheist, until I realized I had nothing to shout during blowjobs. "Oh Random Chance! Oh Random Chance!" just doesn't cut it….
Robert Anton Wilson, 1932 - 2007
|
| |
Sachsenpaule
SENATOR BABYHEAD  Posts: 167 Registered: 11/16/2003 Offline
|
5/10/2005 at 09:10 |
For the case somebody needs it:
schiessen = false;
verpasst = 0;
ebene = 0;
score = 0;
ZielIntervalDauer = 1333;
ZielErzeugungszahl = 5;
//zielkreuz hinzu
_root.attachMovie("mc_maus", "mc_mausdrin", 32000);
_root.attachMovie("zaun", "zaundrin", 31999);
zaundrin._x=300;
zaundrin._y=212;
mc_mausdrin.onEnterFrame = function () {
startDrag(this, true);
}
mc_mausdrin.onMouseDown = function () {
this.gotoAndPlay("schuss");
}
//zufall
function Zufall(){
Zufallszahl = Math.round((Math.random()*10));
return Zufallszahl;
}
//eine Zufallszahl zwischen 1 und 5 erzeugen
function Einsbisfuenf(){
new Zufall();
while (Zufallszahl > 5.1){
new Zufall();
}
while (Zufallszahl == 0){
new Zufall();
}
return Zufallszahl;
}
// Koordinaten aus der Zufallszahl erzeugen
function Koordinaten(){
new Einsbisfuenf();
if (Zufallszahl == 1 ) {
x = 62;
y = 240;
}
if (Zufallszahl == 2 ) {
x = 141;
y = 339;
}
if (Zufallszahl == 3 ) {
x = 243;
y = 193;
}
if (Zufallszahl == 4 ) {
x = 464;
y = 303;
}
if (Zufallszahl == 5 ) {
x = 564;
y = 245;
}
return x;
return y;
}
//zufallerzeugung
erzeugeZiel = function(auge, punkte) {
ebene++;
var erzeugtesZiel = _root.attachMovie(auge, auge + ebene, ebene);
new Koordinaten;
erzeugtesZiel._x = x;
erzeugtesZiel._y = y;
erzeugtesZiel.punkte = 100;
erzeugtesZiel.onEnterFrame = ZielFunktion;
}
ZielFunktion = function() {
if((this.hitTest(mc_mausdrin)) && (schiessen == true)){
this.gotoAndStop("getroffen");
score += this.punkte;
}
}
ZielErzeugung = function(){
var ZielZufallszahl = random(20);
if(ZielZufallszahl = ZielErzeugungszahl){
erzeugeZiel("auge", 10);
}
}
ZielInterval = setInterval(ZielErzeugung, ZielIntervalDauer);
[Edited on 10/5/2005 by Sachsenpaule]
____________________ I used to be an atheist, until I realized I had nothing to shout during blowjobs. "Oh Random Chance! Oh Random Chance!" just doesn't cut it….
Robert Anton Wilson, 1932 - 2007
|
| |
|