PDA

View Full Version : Types



kryton9
25-11-2006, 01:12
Petr, I just registered here on these forums today and am going over some of the past posts.
I saw where you had posted a question about passing byref and gave a vector as an example.

I was going to sit down and create types for:
point just a point or vertec
vec2 a 2d vector
vec2s a 2d vector with speed
vec3 3d vector
vec3s 3d vector with speed
rect rectangle
circle
ngon polygon with equal length sides, angle and number of sides? Not sure have to experiment
tri triangle
col r,g,b color
colA r,g,b,alpha color

well you get the idea, but did you already create types for these, I was thinking we can have an include file that defines
all these common types for us, maybe they are there already, if so , can you tell me where. Thanks.

Petr Schreiber
25-11-2006, 12:04
Hi kryton9,

this are good ideas.
I have not done such a TYPEs include, as I create them for every project from a scratch.

This are my ideas: Each of the 2D primitives should contain member like ".plane" which will specify in which 3D plane it is put. 0 = XY ( default ), 1 = XZ, 2 = YZ

Circle could contain some level of detail ( number of sides ), maybe even totally replaced with nGon.
See this sample:




'
' TBGL Sample polys
'
Uses "TBGL"
Uses "MATH"
Uses "UI"

Dim hWnd As Dword
dim i,n as long

type tNGon
radius as number
sides AS LONG
plane as byte
end type

dim MyPoly(2) as tNGon

MyPoly(1).radius = 2
MyPoly(1).sides = 6

' Almost circle
MyPoly(2).radius = 1
MyPoly(2).sides = 60

hWnd = TBGL_CreateWindow("My Demo - press ESC to quit")
TBGL_ShowWindow

GetAsyncKeyState(%VK_ESCAPE) ' Resets ESC key status before checking
dim a as single
While IsWindow(hWnd)

tbgl_ClearFrame

tbgl_Camera 0,0,5,0,0,0

for n = 1 to 2 ' 1 to 2 in our case

tbgl_BeginPoly %GL_LINE_LOOP

select case val(MyPoly(n).plane)
case 0 ' XY
for i = 1 to MyPoly(n).sides
tbgl_Vertex cos( (2*PI) / MyPoly(n).sides * i ) * MyPoly(n).radius, sin( (2*PI) / MyPoly(n).sides * i ) * MyPoly(n).radius, 0
next

case 1 ' XZ
for i = 1 to MyPoly(n).sides
tbgl_Vertex cos( (2*PI) / MyPoly(n).sides * i ) * MyPoly(n).radius, 0, sin( (2*PI) / MyPoly(n).sides * i ) * MyPoly(n).radius
next

case 2 ' YZ
for i = 1 to MyPoly(n).sides
tbgl_Vertex 0, cos( (2*PI) / MyPoly(n).sides * i ) * MyPoly(n).radius, sin( (2*PI) / MyPoly(n).sides * i ) * MyPoly(n).radius
next
end select

tbgl_EndPoly

next


tbgl_DrawFrame

If GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While

Wend

TBGL_DestroyWindow



Bye,
Petr

kryton9
25-11-2006, 21:35
Petr, my jaw dropped when I saw this. What am I doing thinking of types before I understand TBGL?
Stupid me :)

Here you have these commands: tbgl_BeginPoly %GL_LINE_LOOP
and your formulas, WOW.

I realize I am further back than I thought. I want to get into the cool things without putting the effort and time
as I should. Taking shortcuts has caught up with me.

And last night I came upon this, take a look:
http://www.youtube.com/watch?v=i0ZtcxHUSDQ
Now it has me excited about trying linux (ubuntu) and this cool stuff. I am a sucker for eye candy and neat things like that.
Many hard core people don't like these things, but in the end everyone starts to use them. It makes life fun.
So then that leads to how do you program in linux? Nice to have all the options we have now, but it does make
it hard to focus.

Petr Schreiber
25-11-2006, 22:20
Hi kryton9,

do you want it presented in simplier way ? I can create some explanative images or something.
Good idea fol learning TBGL is in thinAir menu Windows / Options, help tab specify thinBASIC_TBGL.chm.
It covers the TBGL syntax. You can access it after this configuration using menu Help / User help.

Regarding Linux ... this is interesting system, but I think it is hell to programme for it as it has very modular structure and every distribution is slightly different :(.

I had Mandrake and SuSE linux for some time, for experiments. It was easy to develop console like app ( I was surprised they have nothing like EXE file in Linux, compiler just throwed away some binary file with no extension :D ).

But regarding avanced stuff, I think you can target only part of the distributions, if you don't want to became mad :)
Because various distributions can have the same core ( kernel ) but different "graphic layout" which I think is coded slightly differently from case to case.

The worst hell for me was absence of OpenGL hardware acceleration for the laptops Intel graphic card, I did not succeeded even after months, grrr.

But it is nice thing to explore, especially with the "live" distros you just put in your CD drive and after some minutes of loading you can explore the system.

Bye,
Petr

kryton9
25-11-2006, 22:37
Petr, I looked in the help, but didn't know about the way to find TBGL help. I was looking through the modules in thinBasic etc :)

Petr, since you have powerbasic, why are you developing your game engine for thinBasic as opposed to game engine for powerbasic?
Do you have something like TBGL for powerbasic?

I was reading on wikipedia about cross platform programming. They mention SDL, wxWidgets etc. I hope I remember them correctly?
Have you ever looked at these.

After that youtube video, now I am thinking maybe I need to find the perfect cross platform language that will allow me to do all I want.
Also Eros posted a link to Channel9 on the coding monkeys forum, I ran across interesting videos on smart phone and pocket pc programming. I know many new little devices are coming with linux too, like the nokia 770.

It would be nice to have one language you can program to all of these platforms. I am getting too old to learn many many languages and want to focus and master just one that I can do all I want, but it seems harder and harder.

I downloade ubuntu and will try installing it on my notebook. I downloaded the 64bit version. My notebook has an AMD 64 but the OS has always been 32 bit, it will be nice to see a 64 bit OS on there if it works. Then if I can get it going, I will download Beryl.

While doing that I will read more today on my main computer. Thanks for all your help and efforts.

Petr Schreiber
25-11-2006, 22:54
Hi,

I have just very surfacial knowledge of SDL, as my friend used it to develop tanks ( 2D game where you set angles and try to fire ) using C for both Windows and Linux. But I still think he had struggle with doing compilation for both platforms, I will ask him.

Regarding TBGL help : It is simple! Just go to your thinBASIC directory and click on "Help" subdirectory.
There is : thinBasic.chm, thinAir.chm and ... tada ... thinBasic_TBGL.chm

Why am I developing games in thinBASIC ? Because there are simply great people around this language :). The language itself is very very nice.
TBGL could be easily wrapped for PB, but ...

It seems people from PB community are doing more serious stuff than the "games", so I am not sure if it would have use. Around thinBASIC there is more people with games in blood and there is even very friendly atmopsphere - that's all I need. I can still code module in PB ( which I love too ).


Bye,
Petr

ErosOlmi
25-11-2006, 23:14
Kryton9,

I can feel some kind of frustration in your words, correct me if I'm wrong. I say this because I felt something similar in the past trying to find the perfect (for me) development environment. I started to see up/down/left/right and after some months of testing, trying, going back, retry I decided to give up and choose only one that I liked.

I made the decision to dedicate my effort only on one platform and it was Windows. I decided this because I wanted a coherent system, not the perfect one but easy to use, setup, update, configure, standardized. Not to mention it in on the most computers around the world.

Second decision was about development environment. I wanted it easy to use, able to create exe and dll, able to create very optimized code, fast, and possible easy string handling. I decided for Power Basic for the mentioned characteristics. I didn't want the perfect dev environment, I didn't want a RAD system that hide complexity of programming with all those visual candy. I wanted a professional system well supported and with a community.

To make a long story short: important is to take a decision based on whatever consideration but a decision. Than work hard on that direction.

Anyhow, the decision is hard because you have (I have) always the impression that the decision I made was not the correct one. But than I keep working hard again and those bad thoughs go out.

In my opinion the best choice to be platform independant is C++ but my decision was not to be platform independent.

As last word: thinBasic is an interpreter, not a compiler. We cannot put on the same level Power Basic and thinBasic. We use Power Basic every day to create our own applications and one of those application is thinBasic.

Ciao.
Eros

kryton9
25-11-2006, 23:27
Thanks Eros for your thoughts and experience. As Petr mentioned in the previous post to yours, I really enjoy the community here in thinBasic as much as the language. There is enough to keep me busy for sometime with it as it is really an awesome language.
Do you know how happy I am not to see these everywhere {} := ; So thanks for such a clean looking language that is open ended and fast. Maybe someday you will port it over to linux.

Maybe in posting that message it helped me, because it makes sense for me to learn the fundamentals of all of this 3d stuff and what better place than here with thinBasic and you great guys here. It might be a year or two before I get to the level I want to be at. Then the computer world could be quite different.

As far as cross platform, it looks like Java, c, c++ or python eventually Aurora. I don't think Borland is supporting Delphi on linux anymore.
I really like Delphi too, but I hate that := I thought I would get used to it, but it just gets irritating to type it in all the time when you are so used to just putting =

Well off to try ubuntu and see if I can finally tap into 64 bit OS on my notebook. Thanks for conversation guys!!

ErosOlmi
26-11-2006, 00:36
It is a pleasure.
You have a lot of ideas and conversating with you is a continuous discover new possibilities.

Thanks again
Eros