Jump to content

My first game in Javascript (for school)


Recommended Posts

Posted

Try it out! Do note, the AI is a very bad loser.

http://tiny.cc/winandforswinn

 

In any case, has anyone in here ever done Javascript? The game is kind of broken by the bad collision detection once the ball speeds up. If you look at my code (right click the page and 'View page source'), do you see anything that could be done to avoid it skipping past the collision?

 

 

Edit: Woops, forgot all the //comments are in norwegian, if someone tries to navigate the code..

gerbilOFdoom and DarthValeria like this
Posted

The paddle on the left started moving faster when the ball would go towards it. Also, the ball ran out of steam for me and basically just stopped somewhere on the bottom of the screen. Pretty good for a school project, though.

Boothand likes this
Posted

It's expected that everyone's gonna have different results. For me, the ball always lags through the opponent at higher speeds. A friend of mine says it never bugged through, and he even had trouble winning..

 

 

JavaScript is pretty bad for doing games in, try Flash or Java if you're interested in doing web games. ;)

 

Yeah, it's not very pleasant (mouse coordinates... brrr!). Using Javascript because we were supposed to, and we've just started the programming course.

 

I'm not sure what's supposed to happen but when I click on "start game" nothing happens

 

Hmm. What browser are you in? If you have Chrome, that should work...

 

The paddle on the left started moving faster when the ball would go towards it. Also, the ball ran out of steam for me and basically just stopped somewhere on the bottom of the screen. Pretty good for a school project, though.

 

Yeah, that's intended. It does an idle thing while waiting, and when it *sees* the ball half way back, it has a max speed that it tries to stop the ball with. To avoid it running out of bounce, use boostfields©™ to make it go faster (also the only way to beat the computer).

 

 

Edit: Haha, even though I've tried supporting different window sizes, playing the game without the browser in full size makes the AI move wayyy faster and messes up.. stuff. That's also a major facepalm when it comes to games in JavaScript.

Posted

Same here, the start button doesn't work (Firefox). Also, in case you're interested (if I remember correctly) and are sick of typing the "/", you can simply use <script language=javascript>.

Posted

Thanks for those links, @@Didz! Very useful.

 

What annoys me the most is things like, it seems to be a whole lot of trouble to get the accurate mouse position, and if you change the layout of things in the HTML for example, the mouse will be offset once again, after using ugly code to manually align it by eye-measure. Same goes for general behavior of objects when using a smaller window (which in my case also resizes the canvas to fit). As a result, I've had to divide everything by the width of the potentially varying canvas to get the same behavior on different monitors or if people happen to use a resized browser window.

 

I guess somewhere along the way, that went wrong though, and now the game goes crazy if I'm playing it in a resized browser window :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...