Bugreport: Beginning to make Simple Jump n Run already mistakes

Previous topic - Next topic

xxbastianxx

Sorry guys, but I cant get it to work. I just made a .txt file with the editor and used that as my first map ( a set of 1s and 0s like in tut) , it says that it can not open map0.txt ...

Have u got other easy options for me, how i can make my map ? I just dont want it to be too far of the tutorial which i m watching...
It's just a lot nicer if i can see how and if the stuff works, which i'm writing... and if I continue with the tutorial without having the game to work, then it's going to be hard to find out what's the problem.

It would be great if u could post me a code where I can easily see what u did and what i have to do.

Kind Regards,
Seb

kanonet

What says it can not open map0.txt? And when? Are you sure you named it map0.txt now? Is it in the right folder so the program can find it?
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

erico

Quote from: xxbastianxx on 2013-Feb-19
...
Have u got other easy options for me, how i can make my map ?
...

One possible route would be to make your map files out of 0 and 1s inside the code, with a DATA command and then you READ that into an array. I did similar on an old board game.

matchy

In regards to simplicity, why not just use characters to represent tile and pickup indices and then read the file data in code? For example:
Code (glbasic) Select
           
       o###o     
       #S.S#     
       #   #     
o#####o   o####o
#S            S#
#              #
#  *        *  #
#              #
#S      K     S#
o#o#########o##o
     
A data text file doesn't need to be part of the GLB project but just in the local folder. erico's DATA statement suggestion is a perfect start but string arrays work well also, if visual constructing it. Formally, the data text file should be opened and read in code, preferably in index format where each index represents a anim sprite position.

xxbastianxx

Quote from: kanonet on 2013-Feb-19
What says it can not open map0.txt? And when? Are you sure you named it map0.txt now? Is it in the right folder so the program can find it?

It just says "Not Abel to Open Media/mediapp/map0.txt" or so... It s all correct.

xxbastianxx

Quote from: matchy on 2013-Feb-20
In regards to simplicity, why not just use characters to represent tile and pickup indices and then read the file data in code? For example:
Code (glbasic) Select
           
       o###o     
       #S.S#     
       #   #     
o#####o   o####o
#S            S#
#              #
#  *        *  #
#              #
#S      K     S#
o#o#########o##o
     
A data text file doesn't need to be part of the GLB project but just in the local folder. erico's DATA statement suggestion is a perfect start but string arrays work well also, if visual constructing it. Formally, the data text file should be opened and read in code, preferably in index format where each index represents a anim sprite position.


Hey, Ty for your post, but I m just starting to learn programming so I don't rlly know what you mean. Could you show me in code ?

xxbastianxx

I seemed to fix the problem with the map... but now it shows me:

"My Jump and Run.gbas"(59) error : user type is not defined : TYPE TMap is not declared


Code (glbasic) Select

CONSTANT tilesize = 16

//Spielkarte
TYPE TMap // <------------- I have declared it ... ??? WHAT'S WRONG WITH IT!?

data$[]
width% ; height%
scrollx; scrolly
Tilesize% //speichert Frames


FUNCTION Init: Name$

LOCAL chn% = GENFILE ()
LOCAL line$



IF OPENFILE ( chn, name$ ,  1) = FALSE THEN END

READLINE chn, line$
width.self = INTEGER (line$)

READLINE chn, line$
width.self = INTEGER (line$)

DIM self.datas[self.width][self.height]

WHILE ENDOFFILE (chn%) = FALSE
READLINE chn% , line$
LOCAL tile$[]

SPLITSTR (line$, tile$[], ",")

FOREACH tile IN tile$[]


x=0
FOREACH tile IN tile$ []
self.datas$ [x][y] = INTEGER(tile)
INC x
NEXT

INC y
WEND


ENDFUNCTION


FUNCTION Update:



ENDFUNCTION


FUNCTION Render:
FOR x = 0 TO self.width - 1
FOR y = 0 TO self.height -1
SELECT self.datas$[x][y]
CASE 0
CASE 1
DRAWRECT x*tilesize, y*tilesize, tilesize, tilesize , RGB(0, 255 ,0)
ENDSELECT
NEXT
NEXT
ENDFUNCTION

ENDTYPE




Code (glbasic) Select


SETCURRENTDIR("Media") // go to media files


GLOBAL Player AS TPlayer //Spieler erstellen
GLOBAL Map AS TMap //Map erstellen        <------------- should be GLOBAL ... ? What did i miss ?




GOSUB Init
WHILE TRUE


   GOSUB Render
   GOSUB Update


   SHOWSCREEN

WEND

SUB Update:

Player.Update()
Map.Update ()


ENDSUB


SUB Render:

Map.Render ()
Player.Render()



ENDSUB


SUB Init:

Player.Init (100,100)
Map.Init("map0.txt")

ENDSUB




(edited for language, please keep it civil. We do have kids here.  :) )

xxbastianxx

I'm sorry...



"Player.gbas"(72) error : wrong argument type : TYPE TMap is not declared I just can not find the Problem...
It would be awesome if someone could help me .. .

Code (glbasic) Select

TYPE TPlayer

x; y
vx; vy //Vektor x,y
width%
height%
HP%
scrollx; scrolly

//...

FUNCTION Init: x, y, width% = 32, height% = 64

    self.x = x
    self.y = y
    self.vx = 0
    self.vy = 0


    self.width = width
    self.height = height

ENDFUNCTION




FUNCTION Update:

LOCAL width, height
GETSCREENSIZE width, height

//Schwerkraft
INC self.vy, 0.01


//Bewegung
IF KEY(203) THEN DEC self.vx, 1 //links
IF KEY(205) THEN INC self.vx, 1 //rechts
IF KEY(57) AND (Map.CollisionPoint(self.x + 1, self.y + self.height +1) OR Map.CollisionPoint(self.x + self.width -1, self.y + self.height +1)) THEN self.y = -4 //space


//trägheit
self.vx = self.vx* 0.5

LOCAL oldx, oldy
oldx = self.x
oldy = self.y

//grenze
IF self.vy > 8 THEN self.vy = 8
IF self.vy < -8 THEN self.vy = -8


//bewege & kollision
INC self.x, self.vx


IF Map.Collision(self.X+1, self.y+1, self.width-2, self.height-2)
self.x = oldx
ENDIF
INC self.y, self.vy

IF Map.Collision(self.X+1, self.y+1, self.width-2, self.height-2)
self.x = oldx
self.y = oldy

Map.scrollx = - self.x + width/2 + width/2
Map.scrolly = - self.y + height/2 + height/2

ENDIF
ENDFUNCTION


FUNCTION Render:

   DRAWRECT self.x + 1 + Map.scrollx, self.y + Map.scrolly, self.width, self.height, RGB(255,0,0)
   DRAWANIM PlayerImage, 0, self.x + 1 + Map.scrollx, self.y + Map.scrolly


ENDFUNCTION

ENDTYPE

erico

I can´t help much as TYPES and FUNCTIONS are a still bit over me :-[.
But here is pieces of the SOLARIS code to read a board(like a board game) from code:
Code (glbasic) Select
// LOAD MAPA > TABULEIRO
RESTORE MAPA // load map
FOR d=0 TO 11 // generate map data
FOR c=0 TO 11
READ m[c][d] // generate m#
IF m[c][d]<1 // generate t# t$
t[c][d]=4 // paint arrays TABULEIRO/GFX
t$[c][d]="."
ENDIF
IF m[c][d]>0
t[c][d]=4
t$[c][d]="+"
ENDIF
NEXT
NEXT

STARTDATA MAPA:

DATA  1, 1, 1, 0, 0, 2, 2, 0, 0, 3, 3, 3
DATA  1, 1, 1, 0, 0, 2, 2, 0, 0, 3, 3, 3
DATA  1, 1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3
DATA  0, 0, 0, 4, 4, 4, 0, 5, 5, 0, 0, 0
DATA  0, 0, 0, 4, 4, 4, 0, 5, 5, 0, 0, 0
DATA  6, 6, 0, 0, 0, 0, 0, 5, 5, 0, 7, 7
DATA  6, 6, 0, 8, 8, 0, 0, 0, 0, 0, 7, 7
DATA  0, 0, 0, 8, 8, 0, 9, 9, 9, 0, 0, 0
DATA  0, 0, 0, 8, 8, 0, 9, 9, 9, 0, 0, 0
DATA 10,10,10, 0, 0, 0, 0, 0, 0, 11,11,11
DATA 10,10,10, 0, 0,12,12, 0, 0, 11,11,11
DATA 10,10,10, 0, 0,12,12, 0, 0, 11,11,11

ENDDATA


That will result in the following 2d arrays:
m[c][d] = exact numbers on the map (from 0 to 11)
t[c][d]  = map overlay for players (4= empty , 0/1/2/3= player´s ship landed)
t$[c][d]= map overlay for test print (.=space , +=landable spot)

I hope that helps, I´m appending a picture of the board mockup and a TEST PRINT from ingame of the same.

For a jump and run game, the basics on reading a DATA is similar. But I suggest you read from a file, like Matchy stated, so it is easier to change things later.

Ian Price

Without going into any of your code, it really does seem like you are trying to do too much, without even a basic understanding of the language or syntax of GLBasic. It's all very well being adventurous and looking to create the next big thing, but without the proper groundwork to create strong foundations the walls and roof of your code-house will soon start to crack and fall. Leaving a nice mess that nobody can easily fix.

You are having problems even in the basic loading of sprites and images, without going into the horror that can be arrays, TYPES and OOP.

Step back a bit. Try to do something simpler. Get that understanding upto a level where you can eventually move to do something more challenging code-wise. I suggest just working on ONE aspect at a time, then build upon that.

IMPORTANT

Your posts are NOT bug reports, as these are not bugs within GLBasic, but rather your own poor programming/understanding of the principles of GLBasic. If you continue to have problems, please post these in the appropriate GLBasic forum (GLBasic - EN - http://www.glbasic.com/forum/index.php?board=2.0), NOT in BUG REPORTS.

We are here to help, but sometimes you just have to help yourself first. Baby steps lead to big things. Don't try to run before you can walk.
I came. I saw. I played.

xxbastianxx

Hi, thank you for the code!

That should help me make a other map where i can test my programm.


@ Ian. I know that I m new and shouldnt really be doing this kind of big stuff but this project is for school, where we have to make a game (or sth. similar). We allways used Delphi7 before, but I hated it... then I asked a friend if he knew a easier language and he told me that GLBASIC is nice, because you dont have to finish of with a ";" everywhere and the commands are not that complicated... so I started of with a few written tutorials and now I found (then only) complete tutorial on youtube, where step by step we create a game.

I'm sorry to bother you in the wrong section... could you maybe move this Thread where it belongs ? I dont know if I can do that (think i d need to be admin)

erico

Try do the PONG tutorial first then the SECOND GAME tutorial, those should give you a good understandment of how GLB works. :good:

You can´t simply copy parts of code and paste on other codes as it is and expect to work (it can work, but requires knowledge on doing so).

xxbastianxx

Hey, i went thorugh the video once again and he says he saves the map as byte file... what does that mean in GL Basic ?

MrTAToad