PDA

View Full Version : Creating map maker



Willdawg
07-26-2005, 12:06 AM
Okay I'm creating a tilebased engine for a game I'm creating and anyways here's the script in action:
http://www.cyberpunkgame.0nyx.com/mapmaker.html
here's what I have :
<html>
<head>
<title>Map builder</title>
<script type="text/javascript">
map1=new Array(1,1,1,1,1,1,1,1,1,1,
0,1,1,1,1,1,0,1,1,1,
0,1,1,1,1,1,0,1,1,1,
1,1,1,1,1,1,1,1,1,1);



function createmap(map){
//change row
for(k=0;k<map.length/10;k++){
//across
for(i=0;i<map.length/4;i++){
valuex=18*i;
valuey=18*k;
if(map[i] == 1){
document.write('<img src="block.bmp" style="position:absolute;Left:'+ valuex +';Top:'+ valuey +'">');
}
if(map[i] == 0){
document.write('<img src="other.bmp" style="position:absolute;Left:'+ valuex +';Top:'+ valuey +'">');
}
}
}
}
createmap(map1);
</script>
</head>
<body>

</body>
</html>

And here's my problem other.bmp is red yet I can't get it to build the red blocks I don't know what my problem is. So I figured you js experts could tell me the error in my ways :P.

PS. Thanks ahead of time.

Willdawg
07-26-2005, 08:57 PM
no one interested in helping a poor lost soul :).

Willdawg
07-27-2005, 12:21 AM
Although no one really seemed intrested through thinking about it I finally realized the error in my ways. The i was reseting after 10 so only the first ten in the array were being put down. I commented on every part of the code and here it is:

<html>
<head>
<title>Map builder</title>
<script type="text/javascript">
//Linear map array
map1=new Array(0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1);
//function createmap to create map :P
function createmap(map){
//counter to measure place in array
counter=0;
//down row
for(l=0;l<map.length/10;l++){
//across row
for(i=0;i<map.length/2;i++){
//image x value
valuex=18*i;
//image y value
valuey=18*l;
//if array = 1 then blah.bmp
if(map1[counter] == 1){
document.write('<img src="blah.bmp" style="position:absolute;Left:'+ valuex +';Top:'+ valuey +'">');
}
//if array = 0 then block.bmp
if(map1[counter] == 0){
document.write('<img src="block.bmp" style="position:absolute;Left:'+ valuex +';Top:'+ valuey +'">');
}
//add one to the counter
counter++
}
}
}
//call function
createmap(map1);
</script>
</head>
<body>

</body>
</html>

I'm sure eventually someone would've helped me :P.

bubba.daniel
07-27-2005, 12:47 AM
HAHA, or either noone knew what the heck you were doing that was on in the last 1 DAY! lol

jscheuer1
07-27-2005, 02:08 AM
If no one else picks this up I'll have a serious look sooner or later, that doesn't mean I'll be able to crack it.

Willdawg
07-27-2005, 02:51 AM
js I already fixed it. By the way it's for creating maps from arrays for a game I'm working on :P. The working script is on :http://www.cyberpunkgame.0nyx.com/mapmaker.html
and if you're intrested in the game I'm making it's on :http://www.cyberpunkgame.0nyx.com/cyberpunk.html
not really too operational arrow keys to move space to shoot. doesn't work on mozilla sorry(I use it too).
and here's the main site for my game not very good but I just whipped it up:http://www.cyberpunkgame.0nyx.com/ (http://www.cyberpunkgame.0nyx.com)
js thanks again for the help on my other script it was much appreciated. I shouldn't need too much more help from you guys plus most of you don't know anything about making graphical games with javascript :P(no offense).

Twey
07-27-2005, 07:46 AM
This was all in the space of one day fifteen minutes. Have patience! :p

Also, if I may make a suggestion, you never need to use bitmaps for the web. Bitmaps are totally uncompressed, so they take a long time to load. For a low-intricacy image that won't be too messed up if a few pixels get moved around (which a block of colour certainly is!), JPEG format is probably best. If you had a very delicate image, you should use GIF or PNG. PNG is generally better, but IE/PC doesn't support transparency in PNG images. These are examples of "lossless" compression: they don't compress as small as a JPEG, but the final image isn't altered in any way.


Will not work on Mozilla sorry. :eek:
Writing a graphical game entirely in Javascript is quite a venture. Personally, I'd use Java. I did think about this a while back, but it never took off. To get decent graphics, you'd have to manipulate each pixel individually! That's a lot of code.

bubba.daniel
07-27-2005, 04:31 PM
if you're intrested in the game I'm making it's on :http://www.cyberpunkgame.0nyx.com/cyberpunk.html
What the heck is the point of that game?

Move around and shoot at nothing, and what your shooting is an image with an error??

Twey
07-27-2005, 04:57 PM
S/he did say it wasn't finished.

jscheuer1
07-27-2005, 05:13 PM
Move around and shoot at nothing, and what your shooting is an image with an error??Sounds relaxing after debugging about 100 lines of code. :rolleyes:

BANG!

Twey
07-27-2005, 05:25 PM
Haha, yes. I tend to play Quake and ask everyone to change their names to "NullPointerException." I find it helps concentration and aim enormously :p

Willdawg
07-28-2005, 03:53 PM
:P I know it looks like shiat right now and seems to have no point but oh well and to do with the bitmaps. I know they're the worst, I won't use them tis just for testing I could careless. By the way I'm not even close to finished bubba.


edit: I also realize how horrible the website is with those crappy bravenet forums but I'll fix that all eventually. I find creating an engine much more important :P. I'm also just getting back into programming after a 2 year hiatus, So that's why I seem to have no idea about some simple stuff :).

Twey
07-28-2005, 07:19 PM
Seriously, though, you'd have a much easier time of this if you used Java (or even [shudder] Flash).

bubba.daniel
07-28-2005, 07:29 PM
ok sry i thought you were referring us to a complete game.

Willdawg
07-29-2005, 12:40 AM
I know I'd have an easier time with java, but I don't know java. I really haven't played any java games that I like :P. Bubba no problem I realize that it looks like crap right now :). It won't be too hard to make the game. It's gonna be pretty simple, well it would be better if I could throw in some more complexity. Now you guys have made me indecsive, haha.

Twey
07-29-2005, 10:06 AM
Trust me, it will be easier to learn basic Java (especially if you already know Javascript) and use that than to write the whole thing in Javascript. You'll end up with a better result, too - there's only so far you can go with square images in a table.

Willdawg
07-29-2005, 05:52 PM
yeah I guess man I just find javascript so easy :P. I knew the basics of java at one time I could learn it again. but it's the fact that I dunno. It's a pain in the ass finding all the libraries and crap that's why I didn't learn c++ although it's supposed to be the "best" for creating games.

Twey
07-29-2005, 06:56 PM
It's a pain in the ass finding all the libraries and crap
I suggest you get a decent IDE, such as Eclipse (http://www.eclipse.org/) (I'm withholding judgement on NetBeans for now; I've just downloaded it and am having a look).

Willdawg
07-29-2005, 07:33 PM
And IDe stands for? Do you still require the SDK pack from sun with it?
Thanks for the help twey

Twey
07-29-2005, 07:51 PM
Integrated Development Environment.
A good one will list and autocomplete available packages for you.
Eclipse includes the SDK, I believe.

Willdawg
07-29-2005, 08:16 PM
Oh ok I didn't know anything like that existed :P. anyways what do you think of my new layout ? better?
what do you think of my new layout better? :http://www.cyberpunkgame.0nyx.com/index.html

Twey
07-29-2005, 09:48 PM
Nice. Game still doesn't work on Mozilla though...
Which, incidentally, wouldn't be a problem with Java...

Willdawg
07-29-2005, 10:02 PM
heh well java is slower loading and not everyone has the plug-in. I don't know I'm just making excuses because I don't want to learn it right now :P.

Twey
07-30-2005, 09:57 AM
Most browsers will tell the user exactly how to install Java, and it'll take them only a few seconds more. The only browsers likely to not do this are text-based anyway. :p Java is slower to load, but if the user goes onto a page specifically for that applet, they'll be prepared to wait. The problem occurs when Java is used for something like a nav bar, and the user has to wait for it before they can do anything else - the user expects something like that to happen ASAP.

bubba.daniel
07-31-2005, 06:37 PM
Nice new layout... You seriously apall me. Why did you change it, i thought the first one was looking fairly decent... =P what can i say, i havent had the best time doing any of that stuff either.. I am kindof interested in what you are doing... i have read the files and stuff, but i didnt find a clear answer, what are you doing in this game? I read about orcs serfs and such, are you making it a grpg?

Twey, do you have a website? :D

Twey
08-01-2005, 06:38 AM
Not really; I mostly do them for other people. I have a quickly-drawn-up page here (http://www.crystalinity.net/) where I intend to link to interesting stuff by me. I lack inspiration. :p

An RPG? In Javascript? :eek:

bubba.daniel
08-02-2005, 12:29 AM
LOL no grpg, gradual rpg, its like not a real rpg but a mock up if you will.. nice site.... twey, you must just be a guru...!!!!