Topic: Canvas golf anyone? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28155" title="Pages that link to Topic: Canvas golf anyone? (Page 1 of 1)" rel="nofollow" >Topic: Canvas golf anyone? <span class="small">(Page 1 of 1)</span>\

 
racerX
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jun 2006

posted posted 07-04-2006 04:31

I'm trying to make a golf game but it only seems to work in firefox. I think it has to do with scaling the image, but i'm not sure. Can anyone think of a way to scale the image and move it around without using the scale in canvas? Or at least suggest a way it can be done? I tried a few things, but I'm too embarrased to post them so they got deleted. They didn't work anyway. I was trying to use moveTo() but it was wrong. anyway, I'll work on it, but I was hoping a kind programmer could suggest a way for the noob to follow. here's a link to canvas golf range. It's very basic. The guy hits the ball and the ball flies. It's the first step in my game but it won't work in IE or opera as far as I know. At least not on my machine (pentiumIII windose 2000pro).

http://h1.ripway.com/politickler/canvasgolf/CanvasGolfRange.html

thanks in advance for anyone who has some suggestions.

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 07-04-2006 09:25

Check in the reference of the drawimage() method in the Web Applications 1.0 - Working Draft - 6.1.1.9. Images. It can take up to 9 arguments to let you draw and resize parts of an image/canvas.

[edit]

I just check the error console in Opera9, and your script crashes with.

code:
JavaScript - http://h1.ripway.com/politickler/canvasgolf/CanvasGolfRange.html
Javascript URL thread: "javascript:slice=false;hook=false;straight=true;long=false;shooting=true;swing(0);"
Error:
name: TypeError
message: Statement on line 89: Could not convert undefined or null to object
Backtrace:
  Line 89 of inline#1 script in http://h1.ripway.com/politickler/canvasgolf/CanvasGolfRange.html
    document["player"].src = golfer[frame].src;
if (frame < 17)
      Line 1 of unknown script 
    slice = false;
hook = false;
straight = true;
long = false;
shooting = true;
swing(0);



The frame variable is undefined.
How do I know ? I just typed javascript:alert( golfer ); in the address bar. It was fine, then I typed javascript:alert( golfer ); and it was undefined.

Beside that I have to say: Duh! Regarding the visual aspect of the play field I expect to see the camera follow the ball and thus it would have been easier to draw the player using Canvas. Thus my advice to have a look at the reference.

If you keep the player in a regular IMG tag, you can place it with a position:absolute; and set the top and left properties using the same formulas you use to draw the ball in '3d'.

How do you see the game ? will the camera stand still and the player will be moved and scaled to the position of the ball or will the camera jump at the position of the ball once it's stopped ?

[/edit]




(Edited by poi on 07-04-2006 09:41)

racerX
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jun 2006

posted posted 07-04-2006 17:42

I'm planning on having the player and screen jump to the next position after the shot is complete. In my opinion, the visuals are an accurate representation of actual golf. It's meant to simulate the real golf experience. When you actually play golf, this is what you'll see. Besides, I'm not knowledgable enough yet to create such cool effects as following the ball flight. Maybe I'll add it between the shot ending and moving to the new ball position once i learn how to do it. First you see the guy shoot and then switch to the ball landing on the fairway or wherever. All in good time. I'm still learning... even some of the basics. I have no actual computer training. Never even took a computer course. Sad, but I missed the computer revolution. I'm trying to catch up. thanks for looking at the script. Here's a version I got working in opera and IE. Still a problem with golfer[]. Something about not being able to convert from null. But it works. IE was really fast when it worked, but then crashes about halfway through the shot.

http://h1.ripway.com/politickler/canvasgolf/GolfRangeV2.html

I got the script to work by changing
document["player"].src
to
document.getElementById("player").src


update: I got it to work in IE. I was calling an array element that wasn't there.

(Edited by racerX on 07-04-2006 18:13)

TwoD
Bipolar (III) Inmate

From: Sweden
Insane since: Aug 2004

posted posted 07-06-2006 11:49

Lol, it does not only crash the script, it completely crashed the browser, and fast indeed!

/TwoD

racerX
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jun 2006

posted posted 07-06-2006 14:20

TwoD

The second link I posted works fine in all browsers and doesn't crash any of them. Nothing like ignoring peoples posts.
http://h1.ripway.com/politickler/canvasgolf/GolfRangeV2.html
t



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu