Topic:   JavaScript   (Read 13587 times)


0 Members and 1 Guest are viewing this topic.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
JavaScript
« on: August 01, 2009, 05:04:11 PM »
I suppose after studying Java for 3 months this is moving down, but I can't for the life of me comprehend anything Java related. *snarls at Sun Microsystems* JavaScript on the other hand looks delightfully simple, and after making the click that cookies are variables I don't see any reason why I can't make simple games with JavaScript and HTML.

So, anyone else ever tried game making with JC?
I survived the spammage of 2007

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: JavaScript
« Reply #1 on: August 01, 2009, 06:00:42 PM »
I wouldn't use a scripting language to do an entire game, but I don't really know anything about JavaScript.

EDIT - Also, I don't know why Java seems so difficult to you... if you have questions or need some good resources just ask.
« Last Edit: August 01, 2009, 07:06:33 PM by WarHampster »

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #2 on: August 02, 2009, 03:31:22 AM »
Quote
I wouldn't use a scripting language to do an entire game, but I don't really know anything about JavaScript.
Any reason in particular? (just out of curiosity) Do you mean because of actual limitations with JC or because anyone could read the source?

Quote
EDIT - Also, I don't know why Java seems so difficult to you... if you have questions or need some good resources just ask.
Well, for example, after reading Beginning Programming with Java For Dummies 2nd Edition, which is over 390 pages, I still haven't learned how to use a single interface element or graphical component. Further more, I have no visual conception of how objects are made from classes. I know what to type to make an instance of a class, but I don't really see the object.

I suppose allot of my troubles result from not being able to ask a book questions. I'd be overjoyed if you could explain to me how to make a simple GUI app, even something as simple as a text field and a button to print stuff into it.
« Last Edit: August 02, 2009, 03:37:50 AM by Silverwind »
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #3 on: August 02, 2009, 08:49:30 AM »
WOW! JavaScript is awesome beyond anything I've ever seen! The syntax is the nearest thing to GM and SC that I've ever seen, and it does everything! Here, don't waste time reading the rest of my post, go here: http://www.w3schools.com/js/default.asp

I can't believe how easily and quickly I'm learning, and even more amazing is how you can test your code online instantly. I'm nearly on the advanced tutorials already and I've gone through all of the HTML ones just to refresh my memory. Once I figure out how to manipulate graphics I'll be able to make online games!

Rejoice, for the collapse of civiliza- er, I mean... the finding of this wonderful language!
« Last Edit: August 02, 2009, 08:51:51 AM by Silverwind »
I survived the spammage of 2007

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: JavaScript
« Reply #4 on: August 02, 2009, 09:09:53 AM »
Quote
Well, for example, after reading Beginning Programming with Java For Dummies 2nd Edition, which is over 390 pages, I still haven't learned how to use a single interface element or graphical component. Further more, I have no visual conception of how objects are made from classes. I know what to type to make an instance of a class, but I don't really see the object.
 
I suppose allot of my troubles result from not being able to ask a book questions. I'd be overjoyed if you could explain to me how to make a simple GUI app, even something as simple as a text field and a button to print stuff into it.
Oh my... Java isn't nearly that hard. If you had iChat, AIM, MSN, or Yahoo; I could teach you a bit. Simplest thing to do is graphics.

Quote
I can't believe how easily and quickly I'm learning, and even more amazing is how you can test your code online instantly. I'm nearly on the advanced tutorials already and I've gone through all of the HTML ones just to refresh my memory. Once I figure out how to manipulate graphics I'll be able to make online games!
 
Rejoice, for the collapse of civiliza- er, I mean... the finding of this wonderful language!
:) Glad you like it. I've played a few JS games and they don't seem that bad, maybe a bit not as powerful but still pretty good. I've even talked to a guy who created a online chat room in the chat room he built all using JS.


-Gandolf

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #5 on: August 02, 2009, 12:51:16 PM »
Quote
I've played a few JS games and they don't seem that bad, maybe a bit not as powerful but still pretty good.
I haven't played any that were particularly impressive looking, (and not a single RPG) but I guess that's because most developers don't like the idea of someone else being able to copy their code and host the game on their own site. I'm not too thrilled at the thought either as I despise copyright infringement with a vengeance, but JavaScript's simplicity and surprisingly vast list of features have drawn me into its lair. And now... well, now it sets to consume me, at first offering warmth, comfort and cross platform compatibilities... but all the time it waits... waits... and just when I've been lulled into a false sense of security, it STRIKES, biting my head clean off!

Or... something like that. Anyways, it's a pretty cool language. :)
« Last Edit: August 02, 2009, 12:56:47 PM by Silverwind »
I survived the spammage of 2007

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: JavaScript
« Reply #6 on: August 02, 2009, 02:05:11 PM »
Quote
Any reason in particular? (just out of curiosity) Do you mean because of actual limitations with JC or because anyone could read the source?

Mostly because anyone could read the source, but also because scripting languages are really designed to interface with code written in other languages, not to act alone.

EDIT -

Quote
I'd be overjoyed if you could explain to me how to make a simple GUI app, even something as simple as a text field and a button to print stuff into it.


I think Gandolf wrote a tutorial on how to do something like that... check the code exchange section.
« Last Edit: August 02, 2009, 02:26:37 PM by WarHampster »

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #7 on: August 02, 2009, 03:28:45 PM »
Quote
Mostly because anyone could read the source, but also because scripting languages are really designed to interface with code written in other languages, not to act alone.
Ah. I'm using Dreamweaver to design the interface, and JC code can be inserted straight into interface elements. :D
 
Quote
I think Gandolf wrote a tutorial on how to do something like that... check the code exchange section.
Yeah, he PM'd it to me. It looks cool. :)

EDIT:

Progress goes delightfully well. I've got sprites moving in the browser and I've almost got V6 working. I'll post the code soon so you can see it.
« Last Edit: August 05, 2009, 07:14:28 AM by Silverwind »
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #8 on: August 05, 2009, 07:11:42 AM »
Here's a Jing Cast of what I've got so far:
http://screencast.com/t/eu92aBUMAPS

Here's the code for it:
Code: [Select]
<html>
<head>
<title>Image Manipulation Test</title>
<style type = "text/css">
#Obj_roomSprite {
visibility:visible;
position:absolute;
left:5;
top:5;
z-index:1;
}
#Obj_enemySprite {
visibility:visible;
position:absolute;
left:489;
top:489;
z-index:2;
}
#Obj_playerSprite {
visibility:visible;
position:absolute;
left:181;
top:181;
z-index:3;
}
</style>
<script type = "text/javascript">
// Set grid vars.
gridMap$ = new Array (14);
gridMap$  [1] = " 11111111111111";
gridMap$  [2] = " 11110011110011";
gridMap$  [3] = " 11000001000001";
gridMap$  [4] = " 10000020000001";
gridMap$  [5] = " 10000000000101";
gridMap$  [6] = " 11111100000000";
gridMap$  [7] = " 11000000010001";
gridMap$  [8] = " 10100111111001";
gridMap$  [9] = " 10000001001111";
gridMap$ [10] = " 10010000001001";
gridMap$ [11] = " 11000100100101";
gridMap$ [12] = " 10010010000001";
gridMap$ [13] = " 11001000010011";
gridMap$ [14] = " 11111111111111";
var gridSize = 14

// Set player vars.
var playerSpriteX;
var playerSpriteY;
//var playerNewSpriteX
//var playerNewSpriteY
var playerGridX = 14;
var playerGridY = 6;
//var playerNewGridX;
//var playerNewGridX;

var enemySpriteX = 93;
var enemySpriteY = 93;

// Determine the player's sprite coordinates based on its grid coordinates.
playerSpriteX = playerGridX * 44
playerSpriteX = playerSpriteX - 39
playerSpriteY = playerGridY * 44
playerSpriteY = playerSpriteY - 39


function handleKeydown (ev) {
// Work out which keyboard key was typed and store it in the "key" variable.
df = document.forms [0];
key = ( (ev.which) || (ev.keyCode) );
// Reset the newTile$ related vars.
playerNewGridX = playerGridX;
playerNewGridY = playerGridY;

// Check which direction the player is trying to move in.
switch (key) {
case 38: // Up Arrow was pressed.
playerNewGridY = playerGridY - 1;
break;
case 40: // Down Arrow was pressed.
playerNewGridY = playerGridY + 1;
break;
case 37: // Left Arrow was pressed.
playerNewGridX = playerGridX - 1;
break;
case 39: // Right Arrow was pressed.
playerNewGridX = playerGridX + 1;
break;
}

// Check what kind of tile the player is trying to move onto.
gridMapRowX$ = gridMap$ [playerNewGridY];
playerTile$ = gridMapRowX$.charAt (playerNewGridX);
if (playerTile$ == "0") {playerTile$ = "Empty"}
if (playerTile$ == "1") {playerTile$ = "Wall"}
if (playerTile$ == "2") {playerTile$ = "Signpost"}

// Check if the player is walking off the grid.
if (playerNewGridX < 1) {playerTile$ = "Wall"}
if (playerNewGridX > gridSize) {playerTile$ = "Wall"}
if (playerNewGridY < 1) {playerTile$ = "Wall"}
if (playerNewGridY > gridSize) {playerTile$ = "Wall"}

// If the new tile is traversable, move the player onto it.
if (playerTile$ == "Signpost") {
alert ("Signpost: Silver was 'ere!")
}
if (playerTile$ == "Empty") {
playerGridX = playerNewGridX;
playerGridY = playerNewGridY;
}
if (playerTile$ == "Wall") {
playerNewGridX = playerGridX;
playerNewGridY = playerGridY;
}

// Determine the player's sprite coordinates based on its grid coordinates.
playerSpriteY = playerGridY * 44;
playerSpriteY = playerSpriteY - 39;
playerSpriteX = playerGridX * 44;
playerSpriteX = playerSpriteX - 39;
// Reposition the player sprite.

if (key >= 37 && key <= 40) {
element = document.getElementById ("Obj_playerSprite");
element.style.left = playerSpriteX;
element.style.top = playerSpriteY;
}
}
</script>
</head>
<body onkeydown = "handleKeydown (event)" >

 Â   <span id = "Obj_roomSprite"> <img src = "http://209.85.48.12/11610/159/upload/p4557688.gif" /> </span>
 Â   <span id = "Obj_enemySprite"> <img src = "http://209.85.48.12/11610/159/upload/p4557408.gif" /> </span>
 Â   <span id = "Obj_playerSprite"> <img src = "http://209.85.48.12/11610/159/upload/p4557156.gif" /> </span>
 Â   
</body>
</html>

If anyone's got the hankering to get cranking on an online game, learn with me! I'll gladly explain anything I've learnt so far and I assure you that JavaScript is not hard, the language just looks a little confusing at first if (like me) you're only used to GM or SC syntax.

Check out W3S for some brilliant tutorials on both HTML and JavaScript: http://www.w3schools.com/JS/default.asp

Man, I can't believe I'm finally making an online RPG! ;D
« Last Edit: August 05, 2009, 07:13:56 AM by Silverwind »
I survived the spammage of 2007

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: JavaScript
« Reply #9 on: March 18, 2011, 08:30:05 PM »
where do you even find java script. I might not learn it for a long, long while, but I'm curious as to where to get it
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: JavaScript
« Reply #10 on: March 18, 2011, 08:39:05 PM »
JavaScript is in every web browser. Built in, just gotta code and run it in your browser.

x


  • GMG-er

  • **


  • Posts: 247
Re: JavaScript
« Reply #11 on: March 18, 2011, 09:36:29 PM »
You could also turn your javascript game into an iPhone game: http://www.phonegap.com/

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #12 on: March 19, 2011, 07:13:41 AM »
Wow! I'm gonna look into this! :o I know JS better than I know GM.
I survived the spammage of 2007

x


  • GMG-er

  • **


  • Posts: 247
Re: JavaScript
« Reply #13 on: March 19, 2011, 08:19:26 AM »
Quote
Wow! I'm gonna look into this! :o I know JS better than I know GM.

I am currently using it to convert a web app for a wine company, its pretty cool as it basically converts JS/HTML/CSS to Objective-C "intermediate" code and compiles it. Thus you don't have the RAM restriction of normal web-browser JS.

Just throw in a HTML 5 canvass and use JS and you have you're self a nifty iPhone dev platform.

It supports the accelerometer as well as just about anything you can think of, and the best bit is once your done you can just compile it for Android OS, or whatever the hell you like!

http://www.phonegap.com/features
« Last Edit: March 19, 2011, 08:27:42 AM by x »

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: JavaScript
« Reply #14 on: March 19, 2011, 09:19:08 AM »
I've not jumped onto the HTML5 bandwagon yet. What's the idea with canvas?
I survived the spammage of 2007