Map Creator Help
Author |
Message |
Boiq
|
Posted: Tue Sep 16, 2008 10:28 am Post subject: Map Creator Help |
|
|
Hey guys,
I'm currently working on a little project of mine. Here is what i got so far so you can get an idea:
setscreen ("graphics:640;480")
colorback (16)
cls
var y := 20
for i : 0 .. maxy by 20
drawline (0, i, maxx, i, gray)
end for
for i : 0 .. maxx by 20
drawline (i, 0, i, maxy, grey)
end for
That simply creates the grid for my Map Editor program. It is designed for pacman.
Anyways, my next step is to be able to use the arrow keys, and have it set so when you click the Right arrow key for example it will move the highlighted boxed over once to the right. So i'm guessing i'll have to make one of the grid boxes to be lit up, have it move individual, etc.
I'm a little lost so it would be great if you could just expand on the code I got right now to get me on the right track. After i get the basics down, i'll need to be able to click the 'W' character for example, it it will add a pieace of wall onto the grid, etc. So if you could continue on with my code, maybe give a few tips, and also explain what you did to make it proper that would really help me and get me on the right note.
Thanks! |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
S_Grimm

|
Posted: Tue Sep 16, 2008 10:36 am Post subject: RE:Map Creator Help |
|
|
go like this
Draw.FillBox (x,y, size of grid square (x1,y1),colour )
if key = rightarrow then
x := x + size of box
x1 := x + size of box
%%%%
so if your box was 10 pixels, then you would input an variable 10 higher then your stating.
ie (x and y = 0, then x1,y1 =10) |
|
|
|
|
 |
Boiq
|
Posted: Tue Sep 16, 2008 10:42 am Post subject: RE:Map Creator Help |
|
|
Thanks for the reply, I kinda understand what you are trying to say although when I try to type it onto my program I get lost and end up with several errors. If you could, open the code I sent, have a look at it, and add what you just mentioned on to it properly, then that way i can review to it and learn that way. Makes it much easier for me, would that be possible?
Thanks! |
|
|
|
|
 |
S_Grimm

|
Posted: Tue Sep 16, 2008 11:44 am Post subject: Re: Map Creator Help |
|
|
Here is the code you asked for. it's not perfect, but you need to learn where the errors are and how to fix them. your code is still there but slightly modified
Turing: |
setscreen ("offscreenonly")
colorback (16)
cls
procedure grid
for i : 0 .. maxy by 20
drawline (0, i, maxx, i, gray)
end for
for i : 0 .. maxx by 20
drawline (i, 0, i, maxy, grey)
end for
end grid
var x, y : int := 0
var x1, y1 : int := 20
procedure box
Draw.FillBox (x, y, x1, y1, brightred)
end box
var key : array char of boolean
procedure move
Input.KeyDown ( key )
if key (KEY_UP_ARROW) then
y := y + 20
y1 := y1 + 20
end if
if key (KEY_LEFT_ARROW) then
x := x - 20
x1 := x1 - 20
end if
if key (KEY_RIGHT_ARROW) then
x := x + 20
x1 := x1 + 20
end if
if key (KEY_DOWN_ARROW) then
y := y - 20
y1 := y1 - 20
end if
end move
loop
View.Update
grid
move
box
end loop
|
|
|
|
|
|
 |
Zren

|
Posted: Tue Sep 16, 2008 5:11 pm Post subject: Re: Map Creator Help |
|
|
I'd invest some time into 2D Arrays + Tiles-Based Mapping. Simply because x1,x2...etc will become tedious with mapping. Also, you going to be needing a way to store the values of each tile to be able to load later.
Arrays
Tile-Based Mapping: This tutorial actually covers map-editing too.
You coooould do it the way you were. By Drawing the map, saving it as an image, then having each tile a different color then using WhatDotColor for colision. However Tile-Based mapping in much easier to use after you comprehend some of the basic elements. |
|
|
|
|
 |
Boiq
|
Posted: Wed Sep 17, 2008 7:09 am Post subject: RE:Map Creator Help |
|
|
Okay thanks for the help, and I may also try your different method out as well Zren. |
|
|
|
|
 |
|
|