Discussion

Some thoughts on NX after trying out FreeBasic.

0

nousername010 2020-08-21 12:42

I know that FB is pretty much a modified version of a modified version of BASIC, but is it possible to also have variable pointers and function overloading in here just like FB, or will that make the console too complicated?


was8bit 2020-08-21 23:12

Variable Pointers kinda already exist in NX...

Rem player
PX=1
PY=1
Rem enemy
EX=10
EY=10

REM MOVE PLAYER
IF RIGHT(0) THEN CALL MOVEIT(PX,PY,1,0)

REM PX NOW = 2

REM MOVE ENEMY
IF RND(100)=0 THEN CALL MOVEIT(EX,EY,1,0)

REM ENEMY EX IS NOW =11

SUB MOVEIT(x,y,dx,dy)
x=x+dx
y=y+dy
END SUB

The same SUB can effectively change and update both player or enemy variables ;)


was8bit 2020-08-21 23:19

Function overloading is just a fancy way of saying you want the same function name but flexibility for inputs and what it can do...

Same thing can be simulated with a cleverly made SUB

SUB MOVEIT(type$,x,y,dx,dy,in1,in2,out1,out2)

Use TYPE$ to reference what is being moved, use IF THEN to customize code..

Personally, it would be easier to read and problem solve to keep SUBS as specialized as possible...

SUB MOVEPLAYER()

SUB MOVEBULLET()

Etc...


was8bit 2020-08-21 23:22 (Edited)

Also remember, SUBS are already flexible, in that input can be a variable name or an actual value... and return values to a portion that has inputed a value is ignored... where returned values to a portion has inputed a variable will change that variable..


nousername010 2020-08-22 01:41

Thanks for answering! I prefer a bit more control in my program’s code. Somewhere on the freebasic docs, dynamic arrays could be made using variable pointers, so I’ll find a workaround :)


was8bit 2020-08-22 02:46

If you mean changing array sizes, i use a variable for the max index... good for controlling a stack

Alternatively, i use a second array to indicate availability if another index in another array... good for dynamic addition and removal of things like bullets...

DIM XB(BM),YB(BM),DXB(BM),DYB(BM),IB(BM)
XB,YB bullet position
DXB,DYB bullet momentum
BM=max # of bullets
IB= bullet index... if 0 this bullet is unused, if 1 bullet is currently in use

So when adding a bullet, i scan the index for an empty slot, set the index array and load the new bullet... to remove that bullet i simply set that slot to 0

When moving bullets i scan the index and only process the set ones...

If sprites are used, then add SB(BM) to assign a sprite, OR... use a math formula that connects each index to each sprite (1=1 etc)


Timo 2020-08-22 10:48 (Edited)

I know that my BASIC has very limited core functions, it's really inspired by the second generation of BASICs (like AmigaBASIC). It would be a lot of work to make the language more modern and then the question would be, why didn't I use Lua or something similar.

The decision to use a classic BASIC was really more for nostalgic reasons than for easy use. I remembered BASIC as an easy to learn language, but in reality it was mostly that easy, because it was so limited. Adding more modern features and trying to stay compatible would probably end in a mess.


Timo 2020-08-22 10:53

Another point I underestimated at the beginning: It's a lot of work to write documentation for a programming language. When there are questions, I cannot simply link to existing tutorials, because it's all specific LowRes NX stuff. So that's another reason why I don't want to make it more complex.


was8bit 2020-08-22 16:03

I stay away from the more modern stuff as my poor brain cannot "see" the complicated layers of logic all at once... i have to break everything down into little steps or i get confused...

The ease and quickness of getting from idea to game is SO QUICK for the simple games it is fun :)

... it is when i try to make a more complcated game my tired mind often goes "poof" and i cant finish it :/ if i had more than a few minutes to work on a game i could do wonders, but a few minutes here and there is all i have time for :(


Log in to reply.