Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Portable Tile Generation System
Index -> Programming, Turing -> Turing Submissions
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jamonathin




PostPosted: Tue Dec 06, 2005 11:36 am   Post subject: (No subject)

fatboi wrote:
i think what zero said is easier to understand and its what i use to an extent in rpgs and other games that i make

Easier yes, effective yes, good practice no. I too have used that method, and the reason I said that was because azure has already used that method before. There's nothing wrong with it for basic rpg games, its just a lot of loading, and if you ever plan on making your game extensive, I would try to switch over.
Sponsor
Sponsor
Sponsor
sponsor
AzureFire




PostPosted: Tue Dec 06, 2005 6:46 pm   Post subject: (No subject)

jamonathin wrote:
fatboi wrote:
i think what zero said is easier to understand and its what i use to an extent in rpgs and other games that i make

Easier yes, effective yes, good practice no. I too have used that method, and the reason I said that was because azure has already used that method before. There's nothing wrong with it for basic rpg games, its just a lot of loading, and if you ever plan on making your game extensive, I would try to switch over.


Yea, the method he mentioned is very bad for RAM and performance. It's not very professional either. This way makes things a little easyer on the eyes (code-wise and visually).
RedRogueXIII




PostPosted: Tue Dec 06, 2005 7:40 pm   Post subject: (No subject)

just remebered something minor but meh,(about that kind of style)

just remember the order you call your pictures is the same as the layer of appearance, so for the overhead objects all you have to do is draw them after drawing the guy, no need for the whatdotcolor stuff at all.
jamonathin




PostPosted: Wed Dec 07, 2005 1:13 pm   Post subject: (No subject)

RedRogueXIII wrote:
just remebered something minor but meh,(about that kind of style)

just remember the order you call your pictures is the same as the layer of appearance, so for the overhead objects all you have to do is draw them after drawing the guy, no need for the whatdotcolor stuff at all.

True, but that would require more images and more thinking. It'll look better, but if you have 100 bridges or somthing, thats 100 extra images Confused
AzureFire




PostPosted: Fri Dec 16, 2005 8:09 am   Post subject: (No subject)

jamonathin wrote:
code:

setscreen ("graphics:150;150,nobuttonbar,position:center;center,offscreenonly")
colorback (black)
color (white)
cls
var spot : array 1 .. maxrow + 1, 1 .. maxcol + 1 of int
% The +1 is for when the game is running, it checks at maxrow+1 which does not exist . . so lets make it exist

for q : 1 .. upper (spot, 1) %maxrow
    for i : 1 .. upper (spot, 2) %maxcol
        spot (q, i) := Rand.Int (0, 4) %4 means cannot walk there
    end for
end for

spot (1, 1) := 0 %Make the first spot open
var x, y : int := 1 %(x,y) starts at (1,1) which is =0
var xHold, yHold : int := x
var valueHold : string := ""

var key : array char of boolean

proc refresh
    for q : 1 .. upper (spot, 1) - 1    %we cannot go to maxrow+1 so dont
        for i : 1 .. upper (spot, 2) - 1 %we cannot go to maxcol+1 so dont
            color (spot (q, i)+28)
            locate (q, i) %locate properly
            put spot (q, i) .. %put whatever value is there
        end for
    end for
    color (10)
    locate (x, y) %locate where our man is
    put "P" ..
end refresh

loop
    Input.KeyDown (key)
    % Basically the if statements say, if the next spot is NOT 4 and is NOT off screen then go ahead
    if key (KEY_LEFT_ARROW) and y - 1 not= 0 and spot (x, y - 1) not= 4 then
        y -= 1
    elsif key (KEY_RIGHT_ARROW) and y + 1 <= maxcol and spot (x, y + 1) not= 4 then
        y += 1
    end if
    if key (KEY_UP_ARROW) and x - 1 not= 0 and spot (x - 1, y) not= 4 then
        x -= 1
    elsif key (KEY_DOWN_ARROW) and x + 1 <= maxrow and spot (x + 1, y) not= 4 then
        x += 1
    end if
    refresh
    View.Update
    delay (100)
end loop



On the right track, but there's a way for it to be done with less code and easyer for nubs like me Smile. It's really quite similar, just easyer to understand. The only problem is, you have about 202500 unused variables, but it's good for games that won't take a lot of resources.

code:
var block : array -33..(TileWidth*TilesAcross), -33..(TileHeight*TilesDown) of boolean
for d:-32..(TileWidth*TilesAcross)%could also use upper, I didn't think of it at the time :P
    for n:-32..(TileHeight*TilesDown)
        block(d,n):=false
    end for
end for

...Your...
...Map...
...Code...

%all the way to where it draws the picture itself

Pic.Draw(TileImages(strint(Locations(i))),TileWidth * XPositionCounter, TileHeight * YPositionCounter - TileHeight,picCopy)
block(TileWidth * XPositionCounter, TileHeight * YPositionCounter - TileHeight)


Then in your movement code...

eg.
code:

if (KEY_DOWN_ARROW) and y>0 and block(playerX,playerY)=false then
        y-=1
end if


You should keep it AFTER the y>0 or if you get to close to the edge it may crash, thus the array and initialization being (-33)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 20 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: