Bugreport: Beginning to make Simple Jump n Run already mistakes

Previous topic - Next topic

xxbastianxx

Hey guys,

I've just started with programming and im using a Tutorial on youtube to make my first Jump n Run game. I did exactly as it's done in the Video but i get a Bug Report (fatal error)  :'(

The Turorial (I'm German so I needed a German tut...):

No.1
No.2

Bug Report:
GPC - GLBasic Precompiler V.10.104 SN:409de90b - 2D, WIN32Wordcount:34 commandscompiling:C:\Users\SEBAST~1\AppData\Local\Temp\glbasic\gpc_tempg.cpp: In member function `DGInt __GLBASIC__::TPlayer::Update()':C:\Users\SEBAST~1\AppData\Local\Temp\glbasic\gpc_tempg.cpp:47: error: invalid initialization of non-const reference of type 'bool&' from a temporary of type 'bool'C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:1182: error: in passing argument 1 of `void __GLBASIC__::INC(T&) [with T = bool]'*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren

My Codes:
Code (glbasic) Select
SETCURRENTDIR("Media") // go to media files

GLOBAL Player AS TPlayer //Spieler erstellenGLOBAL Map AS TMap //Map erstellen

GOSUB InitWHILE TRUE

   GOSUB Update   GOSUB Render

   SHOWSCREEN

WEND

SUB Update:

Player.Update() Map.Update ()

ENDSUB

SUB Render:

Player.Render() Map.Render ()

ENDSUB

SUB Init:

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

ENDSUB

//Spieler

TYPE TPlayer

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

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

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

    self.width = width    self.height = height

ENDFUNCTION

FUNCTION Update:

//Schwerkraft INC self.vy = 0.5

//Bewegung IF KEY(203) THEN DEC self.vx, 1 //links IF KEY(205) THEN INC self.vx, 1 //rechts

// IF KEY(200) THEN INC self.vy, 2 //oben// IF KEY(208) THEN DEC self.vy, 2 //unten

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

//bewege INC self.x, self.vx INC self.y, self.vy

ENDFUNCTION

FUNCTION Render:

    DRAWRECT self.x, self.y, self.width, self.height, RGB(255,0,0)

ENDFUNCTION

ENDTYPE





Thank You for any Help guys!

Edit: Changed to code tags /Moru

erico

Hello xxbastianxx! Welcome to the boards! :good:

Instead of [spoiler] try paste your code between code, it is the # button over the smiles.
That makes it a lot faster for us to check it out.
It should look like this:
Code (glbasic) Select
SETCURRENTDIR("Media") // go to media files

GLOBAL Player AS TPlayer //Spieler erstellenGLOBAL Map AS TMap //Map erstellen

GOSUB InitWHILE TRUE

   GOSUB Update   GOSUB Render

   SHOWSCREEN

WEND

SUB Update:

Player.Update() Map.Update ()

ENDSUB

SUB Render:

Player.Render() Map.Render ()

ENDSUB

SUB Init:

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

ENDSUB

//Spieler

TYPE TPlayer

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

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

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

    self.width = width    self.height = height

ENDFUNCTION

FUNCTION Update:

//Schwerkraft INC self.vy = 0.5

//Bewegung IF KEY(203) THEN DEC self.vx, 1 //links IF KEY(205) THEN INC self.vx, 1 //rechts

// IF KEY(200) THEN INC self.vy, 2 //oben// IF KEY(208) THEN DEC self.vy, 2 //unten

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

//bewege INC self.x, self.vx INC self.y, self.vy

ENDFUNCTION

FUNCTION Render:

    DRAWRECT self.x, self.y, self.width, self.height, RGB(255,0,0)

ENDFUNCTION

ENDTYPE


I´m not quite familiar with this one tutorial, but someone will be and getting back to you soon.
Again, welcome aboard!

okee

 this should work, i pointed out where the errors were in the code
You'll need to edit what's in the Update(): Function  to match his code
as all it does at the moment is move the box downwards


Code (glbasic) Select

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

GLOBAL Player AS TPlayer //Spieler erstellenGLOBAL Map AS TMap //Map erstellen

GOSUB Init
WHILE TRUE

   GOSUB Update
   GOSUB Render

   SHOWSCREEN

WEND

SUB Update:

Player.Update()
Map.Update ()

ENDSUB

SUB Render:

Player.Render()

ENDSUB

SUB Init:

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

ENDSUB

//Spieler

TYPE TPlayer

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

width% //<###### This was missing
height% //<###### this was missing

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

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

    self.width = width
    self.height = height

ENDFUNCTION

FUNCTION Update:

INC self.vy, 0.5 //<####### this was //Schwerkraft INC self.vy = 0.5 should be , instead of =

IF KEY(203) THEN DEC self.vx, 1 //links IF KEY(205) THEN INC self.vx, 1 //rechts

IF KEY(200) THEN INC self.vy, 2 //oben// IF KEY(208) THEN DEC self.vy, 2 //unten

self.vx = self.vx* 0.8

INC self.x, self.vx
INC self.y, self.vy


ENDFUNCTION

FUNCTION Render:

    DRAWRECT self.x, self.y, self.width, self.height, RGB(255,0,0)

ENDFUNCTION

ENDTYPE

[code=glbasic]
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

kanonet

ATM it cant work, since it is missing a definition of the type TMap.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

okee

i'm assuming the map code is in another source code file as shown in the second tutorial video
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

xxbastianxx

Hey guys,

Yeah sorry, I was looking for that, but didn't find it. Ty for editing it.

TMap is in a other source. I didn't bring that up, because I wanted the player to work first.

Ty for the Help - the "," was the only mistake! ;)  (if u look again I had width, height there - that was correct)

I don't understand why it gives me a bug report which is 100 symbols long just cauz a "," is wrong but ok. ^^

Thank you very much. I ll probably need some more help sooner or later.

Regards,
Seb

mentalthink

Hi xxbastianxx willkomen to the Community!!! but guy  =D I think for your first code your use a very complex thing... go bit a bit... You have all the time in the World  :D

I don't look what's happends but not worry all the people are here, we using GLbasic everyday and runs very fine.. perhaps you find something in the help or another place in the forum don't works, basically the code it's very very old, and somethings going chaiging whit the time... like the good wine  =D !!!

Then only say you wellcome, and try to make more simple things, sure you undertand all the steps for do anything you want...

Regards,
Iván J

xxbastianxx

Haha :) Ty Ivan!



I've got another bug report, but this time it only says "Syntax error" ... -.-'


Code (glbasic) Select

[b]Main Code[/b]

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


GLOBAL Player AS TPlayer //Spieler erstellen
//GLOBAL Map AS TMap //Map erstellen


GOSUB Init
WHILE TRUE

   GOSUB Update
   GOSUB Render

   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.map")

ENDSUB



[b]Map[/b]
CONSTANT tilesize = 16

//Spielkarte
TYPE TMap

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



[b]map0.map[/b]
15   // this is wher it shows me the yellow ARROW of mistake ^^
6
0,0,0,0,0,1,0,0,0,1,1,0,1,0,0
0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
1,0,1,0,0,0,0,0,0,0,1,0,0,1,0
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1



I reffer to the tutorials above.

As I created the "map0.map" I couldnt do it like in the video, I clicked on "other" right click and then create new file... it should of opened map0.map in "Other" but it opened in "Sources" so maybe that could be the Problem, but I dont think so.
I've got a screenshot attached to the post. (Green is where it is in the Vid... Red where it is in my Program)



I really appreciate every help! I honor you guys, who can programm well and find mistakes by them selves, unfortunately I'm not that far jet.

Regards,
Seb

[attachment deleted by admin]

kanonet

In the video he creates "map0.map" which is not a GLBasic file, which means it gets ignored by the compiler. You created "map0.map.gbas" which is a GLBasic file, which is why the compiler checks it. And of cause the map data that you write inside it are not proper GLB syntax, so the compiler is totaly right to give you an syntax error.
Just remove the file from the project, rename it to "map0.map" and add it to the project.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

xxbastianxx

Hey, ty for the idea but it didn't work. The computer allways saves it as .gbas file eventhough i write "map0.map" and press "save". When i open the file, it still shows me "map0.map.gbas"

Why does it do that ? Maybe I ve got some settings wrong ?

Ty for any help!

mentalthink

HI xxbastianxx yes the problem it's because you save the file from GLbasic, alwais you obtain a glbas file, if you want add another file whit another extension, you have to modify out GLbasic, in example if you make a simple txt file and you save whit txt, and then load into the tree of files of GLbasic , you can see this file it's a txt...

GLbasic works whit GLbas files C++ and you can add txt files, fut really I never use never...

don't mind not trouble in this part in C4d, and less in the actual Stable version...

Wellcome to the Boards!!!  :good:  :booze:

kanonet

Yes, just rename it in windows, outside of GLB.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

xxbastianxx


So I can open text editor from windows and put in some numbers like
1,1,1,1
0,1,0,1

and it will create my map in gl basic ? :O Sounds weird.

I'm sorry that this easy problem is taking so long, but in the video, he just saves it under map0.map from gl basic into the media file and it works... (look at no2 video I posted. [04:50 min] ... )

kanonet

A file is a file is a file. As long as you say 'here, use this file!' it does not matter how it was created, it just needs to be there.

No problem, we're here tio help. ;)
The video is old, so obviously something has changed since it was created. GLB is under active development, new features get added etc... From time to time you will find some outdated informations in the helpfile, this forum or 3rd party tutorials, so you need to find a work around if this happens.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

erico

Quote from: xxbastianxx on 2013-Feb-14

So I can open text editor from windows and put in some numbers like
1,1,1,1
0,1,0,1

and it will create my map in gl basic ? :O Sounds weird.

I'm sorry that this easy problem is taking so long, but in the video, he just saves it under map0.map from gl basic into the media file and it works... (look at no2 video I posted. [04:50 min] ... )

It is not that much weird, You can have a map made of 0s and 1s, either read from a file or in a DATA statement, and then get that into an array to draw things.

I tried out the videos, but it is done on a alien language I can´t understand! :S :P

I will look at the code later, try to figure it out.