2019-06-11 13:55:20

Hi there.
I have been thinking for a while now about giving pb a shot. I'm sort of getting the hang of python, but there are just things about it that I don't like. With that out of the way though, I have a few questions.
1. Is there any sort of pb aquivvilent to the sound pool in bgt, or at least something that allows basic sound positioning and playing.
2. What is the best way to go about adding menu support. So far the only pb audiogames I've been able to really mess with are rtr, mason's up offline and sbc, all of which have very different stiles at handling menues. The first two have more the sort of menu I'd want, where as the latter has this weird dialog box thing.
3. How exactly does handling objects, classes, arrays and for loops, etc differ from bgt.
4. How exactly is networking done in pb, both client and server. I couldn't find any clear documentation on this in the pb documentation.
5. Is there any easy way of doing map handling? I've thought of mason's game engine at first, but to my knollige that doesn't have a pb wrapper, or at least I haven't seen one.
6. With all that in mind, would you say pb is worth the price? It seems a little steap at least to me, but I'll sertinitly look into purchasing if I think it's worth it.

2019-06-11 15:40:29

The game engine by Mason is in pure basic, So it definitely has the wrapper for it, and there is an examples folder in the pure basic directory, you can find client and server examples there

everyone in life has something to contribute to this existence, its just if people actually will contribute anything that actually counts

Thumbs up

2019-06-11 16:10:19

Ok, well, I never knew that, and that's after having that engine for quite some time. I'll have to check that out later. I think I've been keeping relatively on top of updates, the version I have right now is 1.00.

2019-06-11 19:47:12 (edited by Ethin 2019-06-11 19:50:57)

1. Yes. PureBASIC supports 2D and 3D sound positioning with the Sound and Sound3D interfaces.
2. Menu support is a very tricky thing at first to do when your going custom. The thing is, what would you want your menu to do? Do you want it to have lockable items? Force feedback?
3. PureBASIC doesn't really have a notion of an "object" and a "class". BASIC in general doesn't, or at least most dialects don't. VsualBASIC and a few other BASICs are exceptions to the rule. Generally, the BASIC dialect PB uses borrows many keywords you already know and adds some new ones: Break : Continue, For : Next, ForEach : Next, Gosub : Return, If : Else : EndIf, Repeat : Until, Select : EndSelect, While : Wend, Define, Dim : ReDim, Enumeration : EndEnumeration, Interface : EndInterface, Module : EndModule, NewList, NewMap, Structure : EndStructure, With : EndWith, Global, Procedure : EndProcedure, Protected, Shared, Static, Import : EndImport, Macro : EndMacro, Prototype, Pseudotype, Runtime, Threaded, and goto. Those are all the keywords (minus a few I missed) that are in PB's dialect of BASIC. The Protected, Shared, ... keywords are for PB's method of object-oriented programming model, which is a far different beast to, say, BGTs or Pythons OOP model. To fully answer your question I'll do it in the order you specified.
Objects: handling objects is a bit tricky in PB because the manual doesn't really explain it well (IMO). The way you declare an "object" in PB is as follows:

Interface <name> [Extends <name>]
  <Method[.<type>]()>
  ...
EndInterface

An example for a menu might be:

Interface Menu
Run(text)
EndInterface

Other than that I unfortunately am not sure how to actually define the methods: the manual is lacking in that regard, which makes it challenging.
Classes: PB (to my knowledge) does not have any form of a "class".
Arrays: Arrays can be defined with the Dim keyword and resized with the ReDim keyword. An example (say, for an instruction emulator) might be:

; Declare our emulators "RAM" space. In this case the emulator will only have 4.01 KB of RAM.
Dim ram(4096)

This has a caveat, however. When you declare an array like this, the array will have 4097 elements (in my example), not 4096. This is because the system will allocate elements 0 to 4096. This can be a gotcha if your not careful. Also, you will need to free the array when your done with it by calling FreeArray().
Another way to declare the array, which also avoids the above caveat, is to use a "static array". Note that the Array library functions will not work on these types of arrays. This is a very advanced way of doing things though and involves Structures.
For loops: For loops are very easy in PB:

For i = 1 To 1000
; code
Next

Or

For i = 1 To 1000 Step 2
; code
Next

Or even

For i = 1 to 1000 Step 5
For j = 1 To 5000 Step 10
; code
Next j
; code
Next i

The above i and j variable references in the for loop is just syntactic sugar allowing you to prematurely advance another loop if you like. That one in particular could've just allowed you to write:

For i = 1 to 1000 Step 5
For j = 1 To 5000 Step 10
; code
Next
; code
Next

You also have the ForEach loop:

; Create a list and fill it with random numbers
NewList numbers()
; Add some elements (say: 50)
For unused_variable = 1 To 50
; I just called it unused_variable to indicate that we [weren't] going to use it.
AddElement(numbers())
numbers() = Random(1000)
Next
; Loop through that list now
ForEach numbers()
; Debug print it!
Debug numbers()
Next

I'm not really sure how this works underneath and do not really understand why the syntax is the way it is (but it is).
4. The networking has examples, go check those out. Also look into the Network library in the PB reference manual.
5. There is! [Woohoo]! You can declare a multi-dementional array like this:

; Declare a 3D array
Dim mdarray(100, 100, 100)
; Fill it with cells!
For x = 1 To 100
For y = 1 To 100
For z = 1 To 100
mdarray(x, y, z) = 1
Next
Next
Next

6. Honestly no, I wouldn't. PB is nice (it provides a lot of features) but doing a lot of OOP or functional programming with it is just going to be a pain. If you want to learn procedural programming though, then this is definitely the way to go. (You may wish to learn C purely to learn how all of this is really done underneath and to master memory management if you want to use PB. Don't let memory management drive you away though -- manually managing memory is awesome!)

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up +1

2019-06-11 20:02:30

Hi Cmerry.
Well I used PB years ago, but I wouldn't recommend it. It's way of doing things never made much sense to me, and the price for it is ridiculous! There are so many free alternatives, c#, python, rust (I think), and some others. If you don't like python there are plenty of other options out there for you. I thought of buying PB a long time ago, but I realized I would be getting something that was not worth the money.'Hth.

Guitarman.
What has been created in the laws of nature holds true in the laws of magic as well. Where there is light, there is darkness,  and where there is life, there is also death.
Aerodyne: first of the wizard order

Thumbs up

2019-06-12 09:58:16

Hi ethin, thanks for your replies.
The sort of menu I'm talking about would be very simple, just moving through the menu with up and down, with moving sounds and music as well. Nothing really special, just something that gets the job done.
I'll take another look at the docs when I have the time and hopefully get the hang of the syntax.

2019-06-12 10:42:24

Probably belongs in another topic, but I would be curious to know what you don't like about Python.

My name is Inigo Montoya. You killed my space bar. Prepare to die!

http://l-works.net

2019-06-12 11:59:51

Mostly just it's kind of weird way of doing things. I've sort of got the hang of it now, but I have a hard time dealing with indentation, not to mention I'm having some issues with cython so having properly secured code isn't really a thing at the moment.

2019-06-12 19:35:28

Hi Cmerry.
Do you use NVDA or jaws? NVDA can automatically detect indentation for you to make it less confusing. However if you are using jaws, munawar has made some nice jaws scripts to detect indentation for you. Either way your covered.
From what you said it sounds to me like your using visual studio, which is fine, but there is another solution. If you want something simple to run code and detect indentation with try EdSharp. It's free and it has NVDA and jaws support. The NVDA support is already built-in, but at the end of the installation you have the option to install jaws scripts if you need those. EdSharp has support for many languages, but python is the main language it uses. What makes this simple is that when you are working with a big python program with multiple indentation levels, the program will automatically call out the level for you. For example, if the indent is at level one that's what it will call out and it goes on like that.
Hth.

Guitarman.
What has been created in the laws of nature holds true in the laws of magic as well. Where there is light, there is darkness,  and where there is life, there is also death.
Aerodyne: first of the wizard order

Thumbs up

2019-06-12 19:48:07

@6, I honestly don't remember how Danny and I created our menus back when we wrote DMPA in PB (I don't have the source code anymore). I would give you the way we do it in an object-oriented fashion (both the way Danny likes to do it and the way I do it) but I doubt it would help.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up +1

2019-06-12 21:02:38

if NVDA, turn on indentation beeps. problem solved. Indenting code is a great habit to get in to regardless.

My name is Inigo Montoya. You killed my space bar. Prepare to die!

http://l-works.net

2019-06-13 16:30:54

Yeah, I've mostly gotten the hang of python, but there are other reasons I'd like to learn pb besides that, mainly that it seems more like what I'm used to from bgt, which is good. About the dmpa menues, I was actually thinking about grabbing that code to see how you did that, but danny's link seems to be dead, so. I haven't been able to try blacksquare either, mainly because I can't get the dam thing to run for some reason.

2019-06-13 19:21:52

Hi.
If you are using the demo version of PB, it won't let you run code that's over a certain amount of lines. Either that or you are getting another kind of error.

Guitarman.
What has been created in the laws of nature holds true in the laws of magic as well. Where there is light, there is darkness,  and where there is life, there is also death.
Aerodyne: first of the wizard order

Thumbs up