PDA

Click to See Complete Forum and Search --> : Game creation



johnie
10-21-2000, 02:45 PM
This is a script from the Swish board it draws a semi random SWF on the screen.

<HTML>
<HEAD>
<TITLE>Find the Ball</TITLE>

<SCRIPT LANGUAGE="JavaScript">
function Randomise(maxValue) {
currentdate = new Date ()
seconds = currentdate.getSeconds()
return (seconds % maxValue);
}

function MakeArray(size) {
this.length = size;
for(var g = 1; i <=size; i++);
{
this[g] = 0;
}
return this;
}

function getSwish() {
swishArray = new MakeArray(20);
swishArray[1] = "tumblers1.swf";
swishArray[2] = "tumblers2.swf";
swishArray[3] = "tumblers3.swf";
swishArray[4] = "tumblers2.swf";
swishArray[5] = "tumblers1.swf";
swishArray[6] = "tumblers3.swf";
swishArray[7] = "tumblers1.swf";
swishArray[8] = "tumblers1.swf";
swishArray[9] = "tumblers3.swf";
swishArray[10] = "tumblers2.swf";
swishArray[11] = "tumblers3.swf";
swishArray[12] = "tumblers1.swf";
swishArray[13] = "tumblers1.swf";
swishArray[14] = "tumblers2.swf";
swishArray[15] = "tumblers3.swf";
swishArray[16] = "tumblers2.swf";
swishArray[17] = "tumblers3.swf";
swishArray[18] = "tumblers2.swf";
swishArray[19] = "tumblers3.swf";
swishArray[20] = "tumblers1.swf";
randSwish = swishArray[Randomise(20)];
return randSwish;
}

</SCRIPT>
</HEAD>

<BODY BGCOLOR="#009900">

<P ALIGN="center">
<SCRIPT LANGUAGE="JavaScript">
document.writeln(" <OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
document.writeln(" codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ");
document.writeln(" ID=Untitled WIDTH=400 HEIGHT=250> ");
document.writeln(" <PARAM NAME=movie VALUE='"+getSwish()+"'> ");
document.writeln(" <PARAM NAME=loop VALUE=false> ");
document.writeln(" <PARAM NAME=menu VALUE=false> ");
document.writeln(" <PARAM NAME=quality VALUE=high> ");
document.writeln(" <PARAM NAME=bgcolor VALUE=#009900> ");
document.writeln(" <EMBED src='"+getSwish()+"' quality=high bgcolor=#009900 loop=false menu=false ");
document.writeln(" WIDTH=400 HEIGHT=250 TYPE='application/x-shockwave-flash' ");
document.writeln(" PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> ");
document.writeln(" </EMBED> ");
document.writeln(" </OBJECT> ");
</SCRIPT>
</P>

</BODY>
</HTML>

Brad; toss in my score script, some sticky shapes-for cursors, and your missle SWF's and we have a complete game.


[Edited by johnie on 10-21-2000 at 02:48 PM]

BradBradleySL
10-21-2000, 07:34 PM
um...sticky shapes?

Brad

johnie
10-21-2000, 08:34 PM
You remember my little button thing?

Draw a shape and then make it 100% transparent. Make it a button and then make the on over state solid. Copy that shape so that you have a bunch of those buttons all over your screen- Group them and then copy it to all of the Frames. Viola- a hash cursor.

johnie
10-21-2000, 08:35 PM
Just make sure that the over state is not filled-

johnie
10-21-2000, 09:14 PM
http://www.geocities.com/jsnider.geo/stickyshapes.swf

Mouse over the square.

Now if you make the insides of those circles (or use sights) transparent and have your missles underneath then you could have a cursor.

BradBradleySL
10-22-2000, 09:45 AM
Right after I asked my question I understood:)
Will fix the game today
Brad

BradBradleySL
10-22-2000, 02:51 PM
Johnie-
I am confused with how the score board works, as well as the random, how does it draw the missiles, um, and how do I get the missile object to be variable a, maybe I am just tired, appreciate your help.

Brad

johnie
10-22-2000, 03:11 PM
You are going to make 3 or 4 swf's.

I recommend a start URL that loads the The game itself. The game itself must be embedded on a HTML. The HTML will contain that script. Make 3 or 4 Missle positions. Add the action in my tutorial on Javascript at http://www.koolmoves.com. You will also have to add that text area. The shapes will contain that get URL action that I have in the tutorial. I believe it was javascript: a=a+1;window.document.textarea[name].text[name]value=a;document.window.refresh.

The last thing you will do is create a URL with the game over section and replay section that will redirect them back to the opener URL.

Okay- I'll make an example.

johnie
10-22-2000, 03:17 PM
the tut is here;

http://www.koolmoves.com./scorekeeper/scoretut.html

BradBradleySL
10-22-2000, 03:31 PM
I get it now, I got confused with what gets what script, etc. etc.

Thanks

Brad

johnie
10-22-2000, 03:35 PM
Originally posted by BradBradleySL
Johnie-
I am confused with how the score board works, as well as the random, how does it draw the missiles, um, and how do I get the missile object to be variable a, maybe I am just tired, appreciate your help.

Brad

The person who original wrote the random script named his movies tumbler1.swf; tumbler2.swf; tumbler3.swf. With the script that is there you can have up to 20 different swfs.

You probably want to name your swf's something besides tumbler. Change the script reflect that.

What the script does is looks at the date and time then generates a semi-random number from that. It then sets up an aray and then assigns it to a var.

Instead of writing the SWF to a page in standard methods it writes it to the page with the javascript write.line calls to the built in form object. Instead of the normal methods it allows you to switch the SWF on the page. This is important because we want to keep var info to keep score.

BradBradleySL
10-22-2000, 03:44 PM
Ahhhh, now I really get it, can't translate javascript that well, but now that i look at it, after what you said I see what you mean. Thanks, i gotta study javascript more.

Brad

johnie
10-22-2000, 04:09 PM
http://www.webmonkey.com

has the best intro to java script tutorial around. It is even better than the Javascript for dummies book.

BradBradleySL
10-22-2000, 05:45 PM
Yeah I have been to webmonkey, my problem with javascript and programming in general is the relation to mathematics, I can memorize all the commands, equations, and such but I have trouble reorganizing them into applications, but I will learn, never should have quit at basic, got to into photoshop and such and just stopped studying:)

Brad

johnie
10-22-2000, 05:48 PM
I was lucky I learned basic first.

My problem was with learning OOP. The classes and inhertance confused me a bit.

BradBradleySL
10-22-2000, 06:03 PM
I am in the process of learning to use Delphi, I am going to try and make a good autotracer, I know there are some really good ones out there, but they cost a fortune, I want to make my own, I think thats the great thing about programming, you can make your own programs, for what you need.

Brad

BradBradleySL
10-22-2000, 06:47 PM
Ok, it didn't work, script error, I am going over it

Brad

BradBradleySL
10-22-2000, 06:50 PM
Ok Johnie-

With your tutorial, you say to add-
<form name="first_form......etc. etc.
do you have to add the <script> before that?

Brad

BradBradleySL
10-22-2000, 07:08 PM
I probally have one little letter in wrong, but here-
tell me if you see anything


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<SCRIPT>var a=0</SCRIPT>

<TITLE></TITLE>

<SCRIPT LANGUAGE="JavaScript">
function Randomise(maxValue) {
currentdate = new Date ()
seconds = currentdate.getSeconds()
return (seconds % maxValue);
}

function MakeArray(size) {
this.length = size;
for(var g = 1; i <=size; i++);
{
this[g] = 0;
}
return this;
}

function getSwish() {
swishArray = new MakeArray(20);
swishArray[1] = "missile1.swf";
swishArray[2] = "missile2.swf";
swishArray[3] = "missile3.swf";
swishArray[4] = "missile2.swf";
swishArray[5] = "missile1.swf";
swishArray[6] = "missile3.swf";
swishArray[7] = "missile1.swf";
swishArray[8] = "missile1.swf";
swishArray[9] = "missile3.swf";
swishArray[10] = "missile2.swf";
swishArray[11] = "missile3.swf";
swishArray[12] = "missile1.swf";
swishArray[13] = "missile1.swf";
swishArray[14] = "missile2.swf";
swishArray[15] = "missile3.swf";
swishArray[16] = "missile2.swf";
swishArray[17] = "missile3.swf";
swishArray[18] = "missile2.swf";
swishArray[19] = "missile3.swf";
swishArray[20] = "missile1.swf";
randSwish = swishArray[Randomise(20)];
return randSwish;
}

</SCRIPT>

</HEAD>
<BODY BGCOLOR="#ffffff">


<CENTER>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" ALIGN="Center" WIDTH="320">
<TR>
<TD><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id=game width=700 height=300 codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0">
<param name="movie" value="game.swf">
<param name="quality" value="high">
<param name="play" value="true">
<param name="loop" value="true">
<param name="bgcolor" value="#ffffff">
<SCRIPT LANGUAGE=JavaScript>
<!--
<form name="first_form">
<input type="number" name="first_text" value="">
</form>
var ShockMode = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
if (navigator.plugins && navigator.plugins["Shockwave Flash"])
ShockMode = 1;
} if (ShockMode ) {
document.write('<embed src="game.swf"');
document.write(' width=700 height=300 bgcolor="#ffffff" quality="high" loop="true"');
document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/">');
document.write('</EMBED>');
} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)) { document.write('<IMG SRC="nonflash.gif" width=700 height=300');
}
//-->
</SCRIPT><NOEMBED><IMG SRC="nonflash.gif" width=700 height=300 BORDER=0></NOEMBED><NOSCRIPT><IMG SRC="nonflash.gif" width=700 height=300 BORDER=0></NOSCRIPT></OBJECT></TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>



Thank you
Brad

johnie
10-22-2000, 07:49 PM
No do not add script tags to it


I see four mistakes and one of them is mine.

1. change the g to i in the top of the script.

2. In the script tags add this var a=0

3. Move the Form above the object tag. Place it right after the <center> tag. Forms do not get placed in <script> tags. That will really screw it up.

4. The script as you have written won't do anything. The writln things were important. You must use them as they were in the original code that I posted .

See if that helps.

I'll throw together an HTML and give it to you.

johnie
10-23-2000, 09:03 PM
The script that the guy used was bad. I'm repairing it now.

this is what it should have looked like if you had done it corectly.

<HTML>
<HEAD>
<TITLE>Find the Ball</TITLE>

<SCRIPT LANGUAGE="JavaScript">
var a=0
function Randomise(maxValue) {
currentdate = new Date ()
seconds = currentdate.getSeconds()
return (seconds % maxValue);
}

function MakeArray(size) {
this.length = size;
for(var g = 1; g <=size; g++);
{
this[g] = 0;
}
return this;
}

function getSwish() {
swishArray = new MakeArray(20);
swishArray[1] = "mov1.swf";
swishArray[2] = "mov2.swf";
swishArray[3] = "mov3.swf";
swishArray[4] = "mov2.swf";
swishArray[5] = "mov1.swf";
swishArray[6] = "mov3.swf";
swishArray[7] = "mov1.swf";
swishArray[8] = "mov1.swf";
swishArray[9] = "mov3.swf";
swishArray[10] = "mov2.swf";
swishArray[11] = "mov3.swf";
swishArray[12] = "mov1.swf";
swishArray[13] = "mov1.swf";
swishArray[14] = "mov2.swf";
swishArray[15] = "mov3.swf";
swishArray[16] = "mov2.swf";
swishArray[17] = "mov3.swf";
swishArray[18] = "mov2.swf";
swishArray[19] = "mov3.swf";
swishArray[20] = "mov1.swf";
randSwish = swishArray[Randomise(20)];
return randSwish;
}

</SCRIPT>
</HEAD>

<BODY BGCOLOR="#009900"> <form name="first_form">
<input type="number" name="first_text" value="">
</form>


<P ALIGN="center">
<SCRIPT LANGUAGE="JavaScript">
document.writeln(" <OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
document.writeln(" codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ");
document.writeln(" ID=Untitled WIDTH=400 HEIGHT=250> ");
document.writeln(" <PARAM NAME=movie VALUE='"+getSwish()+"'> ");
document.writeln(" <PARAM NAME=loop VALUE=false> ");
document.writeln(" <PARAM NAME=menu VALUE=false> ");
document.writeln(" <PARAM NAME=quality VALUE=high> ");
document.writeln(" <PARAM NAME=bgcolor VALUE=#009900> ");
document.writeln(' <PARAM NAME="loop" value="true"> ');
document.writeln( "</OBJECT>");
</SCRIPT>

</BODY>
</HTML>

johnie
10-23-2000, 11:05 PM
Okay,

This is giving me a headache.

This is what I've got:

<HTML>
<HEAD>
<TITLE>Game script</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var a=0
var r1=1
var r2=3
function Randomise(r1, r2) {
if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
else return (Math.round(Math.random()*(r1-r2))+r2);
}
function MakeArray(size) {
this.length = size;
for(var g = 1; g <=size; g++);
{
this[g] = 0;
}
return this;
}
function getSWF() {
sWFArray = new MakeArray(3);
SWFArray[1] = "mov1.swf";
SWFArray[2] = "mov2.swf";
SWFArray[3] = "mov3.swf";

randSWF = SWFArray[Randomise(r1,r2)];
return randSWF;
}

function drawme() {
document.writeln('<BODY BGCOLOR="#009900"> <form name="first_form"><input type=&qtnumber&qt name=&qtfirst_text&qt value=></form>');
document.writeln("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
document.writeln(" codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ");
document.writeln(" ID=Untitled WIDTH=400 HEIGHT=250> ");
document.writeln(" <PARAM NAME=movie VALUE='"+getSWF()+"'> ");
document.writeln(" <PARAM NAME=loop VALUE=false> ");
document.writeln(" <PARAM NAME=menu VALUE=false> ");
document.writeln(" <PARAM NAME=quality VALUE=high> ");
document.writeln(" <PARAM NAME=bgcolor VALUE=#009900> ");
document.writeln(' <PARAM NAME="loop" value="true"> ');
document.writeln( "</OBJECT></center>");
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#009900" onLoad="drawme();">
</BODY>
</HTML>

The problem is that when this loads it replaces the HTML with the whats in the Writeln area instead of the just writting it to the page. If someone knows what I'm doing wrong help please. The other problem is that this should Loop, but is not? Why is it not looping?

johnie
10-23-2000, 11:15 PM
Okay,

I got it the first part to work.

<HTML>
<HEAD>
<TITLE>Game script</TITLE>

<SCRIPT LANGUAGE="JavaScript">
var a=0
var r1=1
var r2=3

function Randomise(r1, r2) {
if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
else return (Math.round(Math.random()*(r1-r2))+r2);
}
function MakeArray(size) {
this.length = size;
for(var g = 1; g <=size; g++);
{
this[g] = 0;
}
return this;
}



function getSwish() {
swishArray = new MakeArray(3);
swishArray[1] = "mov1.swf";
swishArray[2] = "mov2.swf";
swishArray[3] = "mov3.swf";

randSwish = swishArray[Randomise(r1,r2)];
return randSwish;
}

function drawme() {
document.writeln('<BODY BGCOLOR="#009900"> <form name="first_form"><input type=&qtnumber&qt name=&qtfirst_text&qt value=></form>');
document.writeln("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
document.writeln(" codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ");
document.writeln(" ID=Untitled WIDTH=400 HEIGHT=250> ");
document.writeln(" <PARAM NAME=movie VALUE='"+getSwish()+"'> ");
document.writeln(" <PARAM NAME=loop VALUE=false> ");
document.writeln(" <PARAM NAME=menu VALUE=false> ");
document.writeln(" <PARAM NAME=quality VALUE=high> ");
document.writeln(" <PARAM NAME=bgcolor VALUE=#009900> ");
document.writeln(' <PARAM NAME="loop" value="true"> ');
document.writeln( "</OBJECT></center>");
}


</SCRIPT>
</HEAD>

<BODY BGCOLOR="#009900">
<script>
window.onLoad=drawme()
</script>

I just need to get it to do the functions again without erasing the whole thing.

johnie
10-24-2000, 01:44 AM
Guys what we have here is a script that will Draw a Random SWF and display it. Remove the "" from around the loop param to make it loop. This script has many uses.

Note-this only works in IE- I cut the Netscape section.

BradBradleySL
10-24-2000, 10:02 AM
Ok I think I have been away to long, looks like you been busy again. Ok I did try what you suggested, and it didn't work, I see that you found something wrong with the randomizer script. So is the last one the fixed one, ok explain to me which .html this is going to go into, and could you explain to me what was wrong, maybe my ole brain can learn something.

Thanks

Brad

johnie
10-24-2000, 10:51 AM
What you see there is the HTML.

All you have to do is cut and Paste.

In the above example r1 and r2 set the random number variables parameters. What I am asying is in var r1=1 var r2=3 is setting it up so that the computer picks a number between 1 and 3.


Randomise is the actual function that picks the Random number.


MakeArray function does just that it makes an array.
The getSwish function calls the makeArray function and assigns a 3 URL's to the variable array called swishArray.
It then creates a variable called randomswish by choosing one of the three URL's and finaly it returns the URL value to getSwish.

function drawme actually draws the Direct X object (the SWF) to the page. It draws the swf specified in make array. Please note that I chopped the Netscape script and detection from this for debugging purposes- I had several bugs, typing and case errors, when I first put this together.

Then in the Body:

The first line declares the Body section and makes the background green.

The next section declares a new script. The new script calls the function Drawme on load.

I was wanting to just call the drawme function in the SWF. This does not work and its not suppose to. After a document is displayed the writeln and write functions will replace your HTML which means we get no benifit from having or stuff in the function drawme. I had to look that up. I think that what we are wanting to do to make this work is instead of using this: ;window.document.refresh we want to use this ;window.document.reload(). I have yet to try it though. I'm sure I still have a bug somewhere. Anyhow later tonight I have it debugged and ready for you.

The other thing we can do besides use the reload script is to use DHTML to make this work. We may have to.

johnie
10-24-2000, 02:35 PM
I have everthing but the score keeper thing working.

<HTML>
<HEAD>
<TITLE>Game script</TITLE>

<SCRIPT LANGUAGE="JavaScript">
var a=1;
var r1=1
var r2=3
a=a++
function Randomise(r1, r2) {
if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
else return (Math.round(Math.random()*(r1-r2))+r2);
}
function MakeArray(size) {
this.length = size;
for(var g = 1; g <=size; g++);
{
this[g] = 0;
}
return this;
}



function getSwish() {
swishArray = new MakeArray(3);
swishArray[1] = "mov1.swf";
swishArray[2] = "mov2.swf";
swishArray[3] = "mov3.swf";

randSwish = swishArray[Randomise(r1,r2)];
return randSwish;
}

function drawme() {
document.writeln('<BODY BGCOLOR="#009900"> ');
document.writeln("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
document.writeln(" codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ");
document.writeln(" ID=Untitled WIDTH=400 HEIGHT=250> ");
document.writeln(" <PARAM NAME=movie VALUE='"+getSwish()+"'> ");
document.writeln(" <PARAM NAME=loop VALUE=false> ");
document.writeln(" <PARAM NAME=menu VALUE=false> ");
document.writeln(" <PARAM NAME=quality VALUE=high> ");
document.writeln(" <PARAM NAME=bgcolor VALUE=#009900> ");
document.writeln(' <PARAM NAME=loop value=true> ');
document.writeln( "</OBJECT>");
}
function reloadIt() { a=a+1;location.reload();}

</SCRIPT>
</HEAD>

<BODY BGCOLOR="#009900">
<center><form name="first_form"><input type="number" name="first_text" value=></form><script name="ed">
window.onLoad=drawme()
window.document.first_form.first_text.value=a
</script></center>
</body>
</html>

johnie
10-24-2000, 02:42 PM
I hate to say it but I'm thinking perhaps frames are going to need to be involved.

johnie
10-24-2000, 02:44 PM
Oh Yeah, almost forgot. This is what jumps into the get URL line:

javascript:

johnie
10-24-2000, 02:49 PM
Oh Yeah, almost forgot. This is what jumps into the get URL line:

javascript: reloadIt();window.document.refresh


I was thinking though, If I call drawme then it replaces the HTML. Perhaps what we need to do is call drawme but on a Frame instead of itself. This should leave the original code alone and allow us to change the other. HMMMM.....

BradBradleySL
10-24-2000, 09:48 PM
:)You know this is completely different from the original right? Looks less complicated. I think I get most of it. I won't be able to work on it till probally, tomorrow night, and I will try to work on the KoolKit site, as well, since there is so much to add. Busy, busy.

Brad

johnie
10-24-2000, 10:15 PM
I rewrote it.

johnie
10-27-2000, 09:56 AM
I think that I know of a workaround so that we will not have to use Frames for the script. I will work on it tonight.

BradBradleySL
10-27-2000, 12:57 PM
I will try to work on it tonight too, as well as fix a bug on the KoolKit site. I will send you the zip of the KoolKit logo tonight. My internet computer is on the frix. I hope to have it up and running tonight.

Brad

johnie
10-30-2000, 02:55 PM
I got held up.

The way to triple nest quotes is to use " ' &quot;
will fix later tonight.

The fix is rather simple or complicated depending on how you want to look at it. The whole page must be declared as a function and then redeclared. Then when you call the function it'll write the whole HTML.


Its rather complicated and involves tripple nesting quotes which should be imposible but thanks to Front Page's ability and eagerness to change code without you telling it to it is possibe.