Jump to content

2D game


Html

Recommended Posts

  • Replies 78
  • Created
  • Last Reply

Well, yes. See this pseudo implementation of Super Mario in JavaScript as an example.As you can see, the game is, to put it mildly, dull. JavaScript is really not meant to create games, so the above was done more "for the record" rather than to achieve anything really astonishing.

Link to comment
Share on other sites

Depends. If you need speed, no. Animating just one sprite will kill your resources. But a strategy game like checkers, Battleship, or Nethack could work well. Ajax can even supply interactivity with other players, too--but only if you don't mind a short delay (0.5 - several seconds, depending).

Link to comment
Share on other sites

Javascript is not intended to make games. But as a simple answer to your question: Javascript can make 2D games.In fact, If you actually were dedicated to it and knew what you were doing, Javascript could even make 3D games. You'd have to build a whole graphics library out of colored <div> tags and create a system of points and a function to display them in perspective. A project that could take months worth of work.Anyways, if you're going for games, I really recommend flash. Making games with javascript would only be just to show how much it can do.

Link to comment
Share on other sites

Thank you thats great.I'm not looking for anything fancy, 2D style space shooter or something. To build. I was trying to do something like this in visual basic but didn't work out. I can't find any tutorials for that sort of thing. And I'm not really a programmer, kind of casual sort of on and off the subject... :)

Link to comment
Share on other sites

I once made, or rather started making, two games using JS only (they only work in FF and maybe other non-IE browsers). You can see them at http://www.roundeddesign.com/lab/. Basically in "Asteroids" you dodge the asteroids coming down, and in "RPG" you control a character in a rogue-style game. I managed to get the RPG fairly complex, with saving, scrolling, talking, and several (well, 3) areas. However, as soon as I tried to replace the characters with images the processing dropped dramatically (to about one pseudoframe per second). So, ASCII games? Entirely possible. Images? Hmm...

Link to comment
Share on other sites

I must say I actually enjoyed Asteroids a lot :) .The RPG... if you put some background colors, rather than relying on text symbols with a single color (and add more levels of course), it might actually be worth it.

Link to comment
Share on other sites

Wow, nice games. The RPG seems like it could actually have gone pretty far as long as you keep it in text. Maybe if you colored the letters and gave the background a color it would almost look like an 8-bit RPG (Except for Mr Omega being only one pixel big)

Link to comment
Share on other sites

So building graphics using div what..?If you want to make an egg or oval shape, how would you go about that?Can anyone explain about 4K colours? Something about only use of four colours too...As said by more than one poster Javascript isn't for building games, it's just another web programming language, right?

Link to comment
Share on other sites

Javascript is for making interactive sites.There's not limitation on colors, you can have any color from 000000 to FFFFFFAbout the graphics with <div> tags, I saw somebody actually do it before. Here it is: http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm

Link to comment
Share on other sites

Thank you.Right, from reading there on that page / site. The graphics library is a seperate file altogether. I actually thought the computer itself just provided the colours sort of on the spot code... :) This site doesn't provide any examples into graphics...

Link to comment
Share on other sites

The graphics library is a JS files that the person programmed on his own. You load it into your site with <script src="file.js" type="text/javascript"></script>The file uses Javascript to perform calculations and create 1x1px <div> elements styled with background color. Don't ask for more explanations, it requires a lot of thinking. You need to learn geometry in math.

Link to comment
Share on other sites

Right, I'm not trying to change the tone. But telling me not to ask any questions would be wrong...This place is suppose to be a place of questions, even the difficultist of them all. :) "The file uses Javascript to perform calculations and create 1x1px <div> elements styled with background color. "But it depends on the game environment. If it was like that game Mario or something even more complex than that then that would be a challenge?I played that Asteroids game, "A" and "0". Basic display.

Link to comment
Share on other sites

It's just that this starts to get out of the realm of web programming and into videogame programming. You really need more programming knowledge for it. You need to learn the way of thinking necessary to put things into a computer.I was pointing out that graphics library because if you were to build a 3D engine in Javascript you'd need to create lines and fills to connect 3D points.For a 2D game like Mario I'd load image files instead (preferrable GIF files since they're small).For very simple games you can create a matrix of text, as Synook did.You need to know the way of thinking necessary for programming seriously.

Link to comment
Share on other sites

I played that Asteroids game, "A" and "0". Basic display.
:) my games are actually ports from some programs I wrote in TI-Basic for the TI-83+ calculators. No images on them!
If it was like that game Mario or something even more complex than that then that would be a challenge?
Well... yes, it would be a challenge (at least for me) :) . The main problem is not so much the actual graphics (you could use images as sprites, etc) but getting the speed up to satisfactory. The thing is that browsers were not originally designed to have to re-render every nth of a second and so their rendering engines are not built for speed. That is why most browser-based games have to use another platform, such as Flash or Java. Still, some people have done quite well, such as in the link Boen_Robot posted ( http://blog.nihilogic.dk/2008/04/super-mar...javascript.html ).Still, what I said shouldn't stop you from trying - even if it doesn't work you'll still learn alot about JavaScript.
Link to comment
Share on other sites

Oh...I never intended to build anything 3D :) Just a small 2D style space shooter.I'd just have shapes, well make it simple I think.One little square or rectangle moving around using the arrow keys, and then another buttons firing a pixel out of the rectangle space ship.

Link to comment
Share on other sites

:) my games are actually ports from some programs I wrote in TI-Basic for the TI-83+ calculators. No images on them!
HAH! I'd forgotten about those. I remember playing Joust on my TI-85 in math class.
Link to comment
Share on other sites

Those are actually ASM (assembly) games, which can be much more complex (as they run faster because are compiled and don't have to be interpreted line by line). Try writing Tetris in TI-Basic!

Link to comment
Share on other sites

All this talk of TI calculators reminds me of high school math class. No learning whatsoever. My favorite was and always will be Bust A Move.Anyway, just an open note for suggestion. Javascript, though sluggish in some regards (you expect more from and interpreted language?) I think you'd find it much easier to do things with the aid of SVG. I just learned the basics myself, but it's pretty darn interesting what you can apply to it with the help of its DOM features and Javascript. I wrote a simple (and darn good looking) calculator program that combined JS and SVG. SVG will pretty much handle all of the graphical aspects you'd need to worry about, especially basic shapes, while JS is more than up to the programming tasks. SVG lets you embed JPEGs and PNGs if I remember correctly, using XLink. I'm pretty sure Googling "SVG frame by frame animation" will give you the exact answer you're looking for too, once you learn SVG though.However, I did find it irregularly hard to get some decent explanations on how to implement SVG's DOM properly through JS. the W3C documentation was wonderful and all, but I had to rummage around.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...