BlameThePixel!

BTForum » BlameTheOffTopic Forums » BlameTheGeneralOffTopic » Lets get Pixel Flyer to work in Netscape!

Page: [1] []
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
So far I got it to display pixels on the far right (but not move), and have the time go up. Supposedly keydown fires, but nothing happens :(
10.07.03 01:06
Post #1
[Hide Sig (3)] [Profile] [Quote]
[S]ReadMe
Absent
Send PM
Posts: 2820
Threads: 85
Money: £43.42 (D)
(+ Friend)
Not online within the last half an hour
try enclosing it in [code] tags, although i'm not sure if zogger has them enabled.
i do agree that we should try and pixel flyer to work in NS/Moz, maybe if you just posted a link to a text file it'd be easier?

________________
Cant be arsed to remake my sig.
10.07.03 01:20
Post #2
[Hide Sig (7)] [Profile] [Quote]
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
According to NS 7's javascript console, what follows is error free.

However, the pixels dont move left and the worm picture doesnt respond. Suggestions?

Quote:

<html>
<head>
<title>Pixel Flyer!</title>
</head>
<script>
if (window.parent.location != location) {
alert("No parenting for you...\n"+window.parent.location+"\n"+location);
location.replace('missing.php');
}
</script>
<body bgcolor="black" text="white">
<div id="thebody" name="thebody" bgcolor="black" style="position: absolute; top: 0; left: 0" width="300" height="150">
<span id="theworm" name="theworm" style="position: absolute; top: 80; left: 0"><img src="images/flyingright.gif"></span>
<span id="thetime" name="thetime" style="position: absolute; top: 155; left: 330">0</span>
<form method='POST' action='pixelscore.php' name='tosend'>
<input type='hidden' name='time' value='0'>
</form>
<script>
var n = 0
var nextpixel = 150
var stillgoing = true
var time = 0

function keystuff(e) {
var keyChar = String.fromCharCode(e.which);
if (keyChar == 'w') {
if (document.getElementById('theworm').style.pixelTop > 0) {
document.getElementById('theworm').style.pixelTop -= 10
}
}
if (keyChar == 's') {
if (document.getElementById('theworm').style.pixelTop < 150) {
document.getElementById('theworm').style.pixelTop += 10
}
}
if (keyChar == 'd') {
if (document.getElementById('theworm').style.pixelLeft < 300) {
document.getElementById('theworm').style.pixelLeft += 10
}
}
if (keyChar == 'a') {
if (document.getElementById('theworm').style.pixelLeft > 0) {
document.getElementById('theworm').style.pixelLeft -= 10
}
}
if (keyChar == 'p') {
alert("Paused. Click OK to continue.")
}
}

function pixel() {
if (stillgoing) {
var topnum = 80
topnum = Math.round((Math.random()*150)-5.5)
document.getElementById('thebody').innerHTML = document.getElementById('thebody').innerHTML+"<span id='pixel"+n+"' style='position: absolute; top:"+topnum+"; left: 332'>.</span>"
setTimeout("movepixel(\"pixel"+n+"\")", 200)
n++
if (n < 45) {
setTimeout("pixel()", nextpixel)
}
}
}

function timer() {
if (stillgoing) {
time++
document.getElementById('thetime').innerHTML = time
setTimeout("timer()", 1000)
}
}

function movepixel(thepixel) {
if (stillgoing) {
var newtop = Math.round((Math.random()*150)-5.5)
var leftvar = document.getElementById(thepixel).style.pixelLeft
var topvar = document.getElementById(thepixel).style.pixelTop
var wormleft = document.getElementById('theworm').style.pixelLeft
var wormtop = document.getElementById('theworm').style.pixelTop
if (topvar+12 > wormtop && topvar +12 < wormtop+21 && leftvar > wormleft + 17 && leftvar < wormleft +38 ) {
alert("You Lose")
stillgoing = false
document.tosend.time.value=time
document.tosend.submit()
}
setTimeout("if (document.getElementById('"+thepixel+"').style.pixelLeft > -1) { "+
"document.getElementById('"+thepixel+"').style.pixelLeft -= 10"+
"} else {"+
"document.getElementById('"+thepixel+"').style.pixelLeft = 332;"+
"document.getElementById('"+thepixel+"').style.pixelTop = "+newtop+" "+
"}", 0)
setTimeout("movepixel(\""+thepixel+"\")", 200)
}
}
document.captureEvents(1024); //keypress
document.onkeypress = keystuff;
pixel();
timer();
</script>
</div>
</body>
</html>
10.07.03 01:40
Post #3
[Hide Sig (3)] [Profile] [Quote]
[S]ReadMe
Absent
Send PM
Posts: 2820
Threads: 85
Money: £43.42 (D)
(+ Friend)
Not online within the last half an hour
under edit->preferences->advanced->keyboard navigation you might need to turn off automatic keyword searching as you type.

To combat this for all browsers maybe a text input for the keypress event?

<note>I tried it with the auto-search turned off and the movement isn't happening still</note>

________________
Cant be arsed to remake my sig.
10.07.03 02:36
Post #4
[Hide Sig (7)] [Profile] [Quote]
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
yeah i had turned off auto search. It would still work if its on (from what ive seen with sample code), though, but you'll get a beeping sound :D
10.07.03 03:12
Post #5
[Hide Sig (3)] [Profile] [Quote]
[S]Zogger!
Looking For Status
Send PM
Posts: 3954
Threads: 62
Money: £93.82 (D)
(+ Friend)
Not online within the last half an hour
woah, heh.
Yeh I've been wanting to get pixelflyer working in other browsers (including opera, cause I use opera) for ages. I tried once but failed, so I just left it how it was.

And no readme I haven't done code tags yet, although I am intending on doing so, I'm just not sure how to go about it. Could probably split the post by code and /code and then do htmlentities or whatever that function is that does php syntax higlighting on the correct portion of the code.
Not sure about that tho. Could also replace tab with 8 &nbsp;s

________________
You know I'm a dancing machine
10.07.03 22:04
Post #6
[Hide Sig (8)] [Profile] [Quote]
[S]ReadMe
Absent
Send PM
Posts: 2820
Threads: 85
Money: £43.42 (D)
(+ Friend)
Not online within the last half an hour
here's some extracts from my code:
$text = preg_replace("'\\n
(.+?)
\n'sie","'\n
'.htmlentities('\1').'
\n'",$text);

$text = preg_replace("'\\n
(?:n)?(.+?)(?:n)?
\n'si","

Code:\n


\\1

",$text);

________________
Cant be arsed to remake my sig.
11.07.03 00:06
Post #7
[Hide Sig (7)] [Profile] [Quote]
[S]Zogger!
Looking For Status
Send PM
Posts: 3954
Threads: 62
Money: £93.82 (D)
(+ Friend)
Not online within the last half an hour
argh, so clashy. Yeh, I got the code tags working and now they have ruined your code sample. heh. It does php syntax highlighting if you use the php tags, hence the reason it's white. Just as a test

\n
Pixel Flyer!
0

\n

And some php
\n
2) { echo "boo to you too."; } else { echo "boooring..."; } ?> hello \n

edit: okey didn't work right...
edit again: Works now :)

________________
You know I'm a dancing machine
11.07.03 00:35
Post #8
[Hide Sig (8)] [Profile] [Quote]
[S]ReadMe
Absent
Send PM
Posts: 2820
Threads: 85
Money: £43.42 (D)
(+ Friend)
Not online within the last half an hour
there is a PHP formatting function in php u know?

BTW, NS doesn't support object.style.pixelTop, it uses object.top instead.

________________
Cant be arsed to remake my sig.
11.07.03 00:43
Post #9
[Hide Sig (7)] [Profile] [Quote]
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
I'll change the code and see if that makes it work at all.

I'm very close now, thanks to my JS debugger :D

The worm now moves up on command. Its a simple matter to apply it to the rest. Will post finished code soon.
11.07.03 03:22
Post #10
[Hide Sig (3)] [Profile] [Quote]
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
Worm Moves Everywhere
Fixed Hit Detection

Pixels do not yet move.

Zogger:

Quote:

setTimeout("if (document.getElementById('"+thepixel+"').style.Left > -1) { "+
"document.getElementById('"+thepixel+"').style.Left -= 10"+
"} else {"+
"document.getElementById('"+thepixel+"').style.Left = 332;"+
"document.getElementById('"+thepixel+"').style.Top = "+newtop+" "+
"}", 0)

Why surround this in settimeout with a 0 second delay?
11.07.03 05:10
Post #11
[Hide Sig (3)] [Profile] [Quote]
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
Completely working pixelflyer (Netscape only :D):


Quote:

<html>
<head>
<title>Pixel Flyer!</title>
</head>
<script>
if (window.parent.location != location) {
alert("No parenting for you...\n"+window.parent.location+"\n"+location);
location.replace('missing.php');
}
</script>
<body bgcolor="black" text="white">
<div id="thebody" name="thebody" bgcolor="black" style="position: absolute; top: 0; left: 0" width="300" height="150">
<span id="theworm" name="theworm" style="position: absolute; top: 80; left: 0"><img src="images/flyingright.gif"></span>
<span id="thetime" name="thetime" style="position: absolute; top: 155; left: 330">0</span>
<form method='POST' action='pixelscore.php' name='tosend'>
<input type='hidden' name='time' value='0'>
</form>
<script>
//Things used here that wont work in IE:
// -The Set/Get Object Top/Left
// -The decleration for the keypress
// -The way keypresses are checked
//
var n = 0
var nextpixel = 150
var stillgoing = true
var time = 0

function GetObjectLeft(objectname) {
//in NS, these are string variables, like "80px" (the px is pixels)
// we must chop off the px, subtract 10, then add the px back

var obj = document.getElementById(objectname).style;
var answer = 0;

if (obj.left.indexOf("p") != -1){
answer = Number(obj.left.substring(0,obj.left.length-2));
} else {
answer = Number(obj.left); //this is never the case but what the heck
}
return answer;
}

function SetObjectLeft(objectname, newvalue) {
//in NS, these are string variables, like "80px" (the px is pixels)
// we must chop off the px, subtract 10, then add the px back

var obj = document.getElementById(objectname).style;
var answer = 0;

if (obj.left.indexOf("p") != -1){
obj.left = String(newvalue)+"px";
} else {
obj.left = Number(newvalue); //this is never the case but what the heck
}
}

function GetObjectTop(objectname) {
//in NS, these are string variables, like "80px" (the px is pixels)
// we must chop off the px, subtract 10, then add the px back

var obj = document.getElementById(objectname).style;
var answer = 0;

if (obj.top.indexOf("px") != -1){
answer = Number(obj.top.substring(0,obj.top.length-2));
} else {
answer = Number(obj.top); //this is never the case but what the heck
}
return answer;
}

function SetObjectTop(objectname, newvalue) {
//in NS, these are string variables, like "80px" (the px is pixels)
// we must chop off the px, subtract 10, then add the px back

var obj = document.getElementById(objectname).style;
var answer = 0;

if (obj.top.indexOf("px") != -1){
obj.top = String(newvalue)+"px";
} else {
obj.top = Number(newvalue); //this is never the case but what the heck
}
}

function keystuff(e) {
var keyChar = String.fromCharCode(e.which);

var wormname = 'theworm';
var wormtop = GetObjectTop(wormname);
var wormleft = GetObjectLeft(wormname);

if (keyChar == 'w') {
if (wormtop > 0) {
wormtop -= 10;
}
}
if (keyChar == 's') {
if (wormtop < 150) {
wormtop += 10;
}
}
if (keyChar == 'd') {
if (wormleft < 300) {
wormleft += 10;
}
}
if (keyChar == 'a') {
if (wormleft > 0) {
wormleft -= 10
}
}
if (keyChar == 'p') {
alert("Paused. Click OK to continue.")
}
SetObjectTop(wormname, wormtop);
SetObjectLeft(wormname, wormleft);
}

function pixel() {
if (stillgoing) {
var topnum = 80
topnum = Math.round((Math.random()*150)-5.5)
document.getElementById('thebody').innerHTML = document.getElementById('thebody').innerHTML+"<span id='pixel"+n+"' style='position: absolute; top:"+topnum+"; left: 332'>.</span>"
setTimeout("movepixel(\"pixel"+n+"\")", 200)
n++
if (n < 45) {
setTimeout("pixel()", nextpixel)
}
}
}

function timer() {
if (stillgoing) {
time++
document.getElementById('thetime').innerHTML = time
setTimeout("timer()", 1000)
}
}

function movepixel(thepixel) {
if (stillgoing) {
var zeWorm = document.getElementById('theworm').style;
var zePixel = document.getElementById(thepixel).style;

var newtop = Math.round((Math.random()*150)-5.5) //new top for next pixel

var leftvar = Number(zePixel.left.substring(0,zePixel.left.length-2))
var topvar = Number(zePixel.top.substring(0,zePixel.top.length-2))
var wormleft = Number(zeWorm.left.substring(0,zeWorm.left.length-2))
var wormtop = Number(zeWorm.top.substring(0,zeWorm.top.length-2))
if (topvar+12 > wormtop && topvar +12 < wormtop+21 && leftvar > wormleft + 17 && leftvar < wormleft +38) {
alert("You Lose")
stillgoing = false
document.tosend.time.value=time
document.tosend.submit()
}
/*
setTimeout("if (document.getElementById('"+thepixel+"').style.Left > -1) { "+
"document.getElementById('"+thepixel+"').style.Left -= 10"+
"} else {"+
"document.getElementById('"+thepixel+"').style.Left = 332;"+
"document.getElementById('"+thepixel+"').style.Top = "+newtop+" "+
"}", 0)
*/
if (GetObjectLeft(thepixel) > -1) {
SetObjectLeft(thepixel, GetObjectLeft(thepixel) - 10);
} else {
SetObjectLeft(thepixel, 332);
SetObjectTop(thepixel, newtop);
}

setTimeout("movepixel(\""+thepixel+"\")", 200)
}
}
document.captureEvents(1024); //keypress
document.onkeypress = keystuff;
pixel();
timer();
</script>
</div>
</body>
</html>
11.07.03 06:09
Post #12
[Hide Sig (3)] [Profile] [Quote]
[S]Zogger!
Looking For Status
Send PM
Posts: 3954
Threads: 62
Money: £93.82 (D)
(+ Friend)
Not online within the last half an hour
readme: yes, I know that, how do you think I'm doing the syntax highlighting? :P

Whiz: Yeh, I surrounded it in an instant setTimeout so that I could refer to the object with the given name, however I think it's not needed using GetElementById (duh is me).
and that only works in netscape, then?

________________
You know I'm a dancing machine
11.07.03 19:42
Post #13
[Hide Sig (8)] [Profile] [Quote]
[S]CBWhiz
Looking For Status
Send PM
Posts: 1044
Threads: 130
Money: £1343.20 (D)
(+ Friend)
Not online within the last half an hour
Yep, the code I just posted works only in NS (and possibly similiar browsers, like Mozilla).

Whether or not it works in Opera depends on which 'standards' Opera chose to support :D
11.07.03 23:32
Post #14
[Hide Sig (3)] [Profile] [Quote]
[S]Zogger!
Looking For Status
Send PM
Posts: 3954
Threads: 62
Money: £93.82 (D)
(+ Friend)
Not online within the last half an hour
can't remember what opera supports exactly, I'm pretty sure some very exact specifications are listed on the opera website tho.

________________
You know I'm a dancing machine
12.07.03 00:22
Post #15
[Hide Sig (8)] [Profile] [Quote]
Page: [1] []

Post Reply

Jump To:


Your Comments:

Donate to BlameThePixel:
Donate to BTP Via PayPal


[22 Queries, Page Loaded in 0.408565 Seconds]

ShoutMeUp

Xmas Greetings from waka waka waka waka []Unvalidated EmailChristmasRiddle MERRY CHRISTMAS EVERYONE! []Spleet Except for Spleet. []TheAbdBoy Always bummin' a brother out. []Spleet Happy New Year everyone! But Spleet. []TheAbdBoy

Word Association

All

-10 Ago-

MiddleEastern []AlphaWolf camel [S]Bloopy toe []TheAbdBoy moose knuckle [S]Bloopy MeatLoaf []Spleet IdDoAnything4Lo ve []AlphaWolf rub n tug []TheAbdBoy tugboat []The Pope rope [S]Bloopy race []TheAbdBoy

-Latest-


Must be logged in to add new words

FictoLeague

You have to be logged in to vote...

Member Stats

Date: 21.11.24.
Members: 4731.
Latest: []Unvalidated Emailsdsakldsaldklasdsdsa
Active:
0 user(s)
1 guest(s)

On chat:
Lots of people

Files: 3330

Bloopy's Site
Get Firefox Get Opera Donate to BTP Via PayPal