What if I want multiple variables?

Blitz3D Forums/Blitz3D Beginners Area/What if I want multiple variables?

iHateMath(Posted 2015) [#1]
I'm new to Blitz3d and I don't know how to store two stuffs in 1 variable.

thingie = 24, 54

and what does it mean by putting # or $ at the variables?

thingie#, thingie$


(tu) ENAY(Posted 2015) [#2]
$ is a string
# if a float
% is an int

(If you don't put anything, default is %)

You are probably looking for arrays.

dim thingie%[1]

thingie%[0] = 24
thingie%[1] = 54


iHateMath(Posted 2015) [#3]
I want to use Text function to display my mouse position.

Text 10, 10, (mousex, mousey), false, false

but it gives me an error...do you guys know how to fix?


(tu) ENAY(Posted 2015) [#4]
You might want to look at the excellent 3D docs for the basics of Blitz3D. There's tons of cool stuff in there that you can literally copy and paste and then compile right from the IDE.


Matty(Posted 2015) [#5]
Documentation is good......

What you are after in your case though is a method for joining two strings together to form a larger string...called concatenation....google is your friend!


Hardcoal(Posted 2015) [#6]
You call you self math hater and you want to be a programmer..
Sounds kinda of a conflict there.
I hope you wont end frustrated.
Just showing some Empathy.. Good Luck..

Also its recommended That you will post those questions in Blitz3D Help Section next time :)

http://www.blitzbasic.com/Community/topics.php?forum=5


videz(Posted 2015) [#7]
Check this code I got from other site docs

Graphics3D 640,480, 0, 2

SetBuffer BackBuffer() 

Repeat 
Cls 

Text 320,0,"Click to reset mouse",True 

Text 0,0,"Mouse X:"+MouseX() 
Text 0,10,"Mouse Y:"+MouseY() 

If MouseDown(1) Or MouseDown(2) Then MoveMouse 320,240 

Text MouseX(),MouseY(),"X",True,True 

Flip 

Until KeyHit(1) 

End



As all these guys already said. Blitz has excellent docs to get you started. It takes some patience and being resourceful to get you somewhere, and google is your friend ;-)


P.S: Don't hate math, it is crucial for game dev or just anything related to programming. At least learn the basics or novice stuff.


videz(Posted 2015) [#8]
For matching your question above. you need to do it this way with the sample I post above..

Text 0,0,"Mouse Pos:"+MouseX() + "," + MouseY() 


Where MouseX() and MouseY() is the default method of getting mouse position


Qube(Posted 2015) [#9]
I'm new to Blitz3d and I don't know how to store two stuffs in 1 variable.

You can only store one value per variable. For example (based on B3D)
myVar$ = "Hello"
myVar% = 1
myVar# = 1.5

If you need multiple values per variable then as Enay says you need to use Arrays. To keep it easy if you need two values at a time then you can use a multiple dimensional array.
Dim myArray%[1,1]

myArray%[0,0] = MouseX()
myArray%[0,1] = MouseY()
myArray%[1,0] = MouseX()
myArray%[1,1] = MouseY()


There are of course other ways to store multiple values in a string like :
myVar$ = "1,2,3,4,5,6,7"

But then you have to write a routine to split it up, so it would be easier to use arrays unless there is a specific reason you can't.


(tu) ENAY(Posted 2015) [#10]
i think though, from a posts = 4 guy, I'd be spending a lot of time getting to grips with the basic concepts of programming first before getting deep into graphics and games.


RemiD(Posted 2015) [#11]
You can use several dim arrays or a type list to store the properties of a thing :

with dim arrays :
global ThingsCount%
Dim ThingName$(10)
Dim ThingAge%(10)
Dim ThingWeight#(10)

ThingsCount = ThingsCount + 1
Id% = ThingsCount
ThingName(Id) = "RTMRTF"
ThingAge(Id) = 21
ThingWeight(Id) = 75.5


with a type list :
Type Thing
 Name$
 Age%
 Weight#
end type

t.Thing = new Thing
t\Name = "RTMRTF"
t\Age = 21
t\Weight = 75.5


As others have already said, i suggest to read the manual, search for related posts on the forum and read these posts.


Zethrax(Posted 2015) [#12]
Pretty much every question you're asking here is answered in the Blitz3D manual. Instead of wasting people's time by asking ridiculously basic questions, I'd suggest you go read that.


big10p(Posted 2015) [#13]
I've no problem with people asking basic questions, just as long as it's in the right forum. There's a Blitz3D Beginners Area forum for this stuff. The description "New to Blitz3D? Confused? Post here for help!" says it all. :)


RemiD(Posted 2015) [#14]
(by the way "RTMRTF" means : read the manual, read the forum) ;)


Blitzplotter(Posted 2015) [#15]
The IDeal IDE for B3D has excellent access via the help drop down which provides you with examples of all commands in B3D.


_PJ_(Posted 2015) [#16]
Pretty much every question you're asking here is answered in the Blitz3D manual. Instead of wasting people's time by asking ridiculously basic questions, I'd suggest you go read that.

If you feel your time is wasted, why did you take the time to respond?
Really your comment comes across as arrogant and elitist.

Any questions will be "ridiculously basic" to a sufficiently experienced developer, and bear in mind that everyone had started somewhere.

Yes, there are answers to be found in the documentation and tutorials which would certainly be a good place to start, but I don't feel that anyone should be criticised for asking what is a genuinely reasonable question.
The OP has clearly given some time to attempt their won coding and are not asking such open and impossible questions such as "how do I make x game?" - instead, they have a query regarding the syntax of the language and need some help with the available functions (even users here for decades are unaware or forget about some of the built-in commands and their uses)

___


@OP As mentioned by others, you will find the documentation and tutorials invaluable whilst getting to grips with the basic workings of Blitz, so it is always recommended you have a good look there.
There are usually a few different ways of solving a problem, and some may be more suited to your requirements than others.
For example, one that has not yet been suggested:

Mouse=( ( (MouseY() And 65535) Shl 16 ) Or ( MouseX() And 65535 ) )
Text 0,0 Str( (Mouse And 65535) )+","+Str( ((Mouse Shr 16) And 65535) )


This relies on Blitz using 32-bit Bytes for each Integer Variable. Since it's highly unlikely anyone will have monitor resolutions of 65535 pixels or more in any dimension, then you can store two values up to 65535 within a single Integer.


Mikorians(Posted 2015) [#17]
It's not mousex and mousey, it's mousex() and mousey(), btw...