Recent posts

#1
OxygenBasic Examples / Function questions
Last post by Frank Brübach - Today at 08:38:51 PM
Tested this function type Yesterday but Second example doesn't Work


'function fu( a=20 as long, b=22 as long ) as long 'dont go
'function f( byval a=20 as long, byval b=22 as long ) as long ' dont go

'1) go
function fu( byval a as long, byval b as long ) as long 'go
a=20
b=22
function=a+b
end function

print fu(1,2) ' result 42 ok
print "ok1"

'2) dont go
function fu2( byval a=20 as long, byval b=22 as long ) as long 'no go?
function=a+b
end function

'print fu2(1,2) 'not ok
print "ok2"

'fu2(b=4)
' dim byref a ' works some years ago too ;)

Now I am Off ;)
#2
OxygenBasic Examples / Re: String Stack class expl
Last post by Theo Gottwald - Today at 12:23:29 PM
📚 I'm fascinated by the concept of using Stacks and Queues as data types!

🗂� It's essential to include a method to get the element count.

🔄 Moreover, having two types of POP instructions is clever:
1. 🔥 A destructive version that truly removes the element.
2. 📝 And another that simply makes a "copy" — ensuring functionality and versatility.

Let's embrace the power of structured data! 🚀

#Coding #DataStructures #TechTalk #ProgrammingTips #StacksAndQueues 😎👨�💻👩�💻🔄🗂�💡
#3
🔥 In 1709, the Swedes were decimated at the Battle of Poltava, outmaneuvered by a superior Russian army & its heavy artillery. 💣
🌍 Back then, much of what is now Ukraine was nestled within the Polish-Lithuanian Commonwealth. 🗺�

💨🍂 Fast forward: The French, led by Napoleon, faced destruction during their harrowing retreat from Moscow. ❄️📅 In 1941, Hitler's ambitions stretched too far. By the Battle of Kursk in '43, the writing was on the wall. 🛑🇺🇸 Today, we witness the hubris of the US, echoing past errors. History's lessons are harsh and clear... 🎓

🔄 Will we see a repetition or learn in time? The stakes are high - the outcome affects us all. ☠️

🌍 The stage is set, with nations lined up for a potential conflict. 🥁💥
🇫🇷 #France
🇬🇧 #Britain (the fiercest proponent)
🇱🇻 #Latvia
🇪🇪 #Estonia
🇱🇹 #Lithuania
🇩🇰 #Denmark

But here's the burning question: 🔥🤔
Can #NATO send troops to Ukraine without declaring war on Russia? 🇺🇦🆚🇷🇺

Is Europe on the brink of another continental war on its soil? 😱🌍

#EuropeanSecurity #GlobalPolitics #ContinentalConflict ✌️🕊�🔍

🔗🌐📣#HistoryRepeats #Poltava1709 #NapoleonicWars #WWII #ColdHardLessons #GlobalPolitics 🌐📚💡⚔️💥🕊�


#4
OxygenBasic Examples / Re: Relational expressions
Last post by Charles Pegge - Today at 12:51:56 AM
Hi Aurel,

You cannot do bitwise/logical operations with floats directly, but you can do this:

i = (a<>0) | (b<>0)

o2 also supports boolean conditionals for both floats and strings as well as integers.

if a then print "ok"

#5
OxygenBasic Examples / Relational expressions
Last post by Zlatko Vid - Yesterday at 10:00:28 PM
Hi Charles

did i test this code properly
looks that AND and OR expressions not work
work with NUMBERS but with variables not

'test relation operators in o2
float a,b
int i

a= 10 : b =15
i = a > b
print i      ' result 0 ..ok!
i = a < b
print i      'result -1...ok!
i = a != b
print i      'result -1 ..ok

'i = a | b    'assembler error
'i = b & a     'assembler error
#6
OxygenBasic Examples / String Stack class expl
Last post by Frank Brübach - Yesterday at 07:16:21 PM
Here is another useful oxygen example with class Methode Style

String Stack

'-- string stack is a special form of a linear data struct
'-- like LIFO last in first out, push and pop
'-- here string concatenation

'=================
 class StringStack
'=================
  string buf
  sys pb
  sys lb

    'APPEND STRING AND ITS LENGTH
    '
    method push(string s) 
   '====================
    sys ls=len s
    sys pn=pb+ls+4
    '
    'ELASTIC BUFFER
    '
    if pn>lb then
      buf+=nuls 4000
      lb=len buf
    end if
    '
    'APPEND STRING AND ITS LENGTH
    '
    mid (buf,pb+1)=s 'APPEND STRING
    pb+=ls
    sys p=*buf + pb
    *p=ls 'PATCH IN LENGTH AS LONG BINARY
    pb+=4
  end method
 
 
  method pop() as string
 '=====================
    if pb<4 then return ""
    '
    pb-=4         'POINT TO ITEM LENGTH ENCODING
    sys i=*buf+pb 'LENGTH OF ITEM
    sys ls=*i
    pb-=ls        'POINT TO START OF STRING
    '
    return mid buf,pb+1,ls
  end method
end class
 
StringStack s
 
s.push "Animal World"
s.push "Hello my"
print s.pop +"  "+s.pop

And now its time for a Break

Regards Frank (Hospital visits)
#7
OxygenBasic Examples / Re: Moving objects opengl
Last post by Frank Brübach - February 25, 2024, 10:39:23 PM
Yes I See my little mistake thank you Charles :)

Updated Version of example one

Oxygen consoleG (OpenGL)
' -- oxygen example openGL by frank bruebach, 22/24-02-2024
 ' -- how to move object 8 slowly ? mousemovement is too fast
 ' -- updated version 2
 
 #compact
 % Title "ConsoleG Demo:  Move text+objects with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
  % Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  $filename "t.exe"
 'uses RTL64
  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  sub main
  ========

  'WaitForEvent '0 off 1 on (default on)
  static int  z, y, x
  static quad t1,t2,t3,t4
  static int x,y,z

  if opening then 'FIRST CALL ONLY
    timemark t1
    picked=100
    'mbox "hello"
  end if
  '
  if opening then 'FIRST CALL ONLY
    timemark t3
    picked=300
    'mbox "wall"
  end if
 
  if opening then 'FIRST CALL ONLY
    timemark t4
    picked=400
    'mbox "cuboid"
  end if

  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    'exit sub
  end if

  cls
  pushstate
  color 1,.5,0,1
  UserMovement m1,100 'identity in steps of 100
  scale 2, 3
  move -6,1.5
  print "Hello Batman "
  popstate
  move 5

  pushstate
  color 1,1,0,1
  UserMovement m2,200
  scale 4
  move -2,2
  print "World"
  popstate


  pushstate
  color 1,1,0,1
  UserMovement m3,300
  scale 2
  move -10,-5
  print "Wall"
  popstate

  if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'kypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    macro pr(a,b,c) 'PRINTING LIST
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 8 : print b : popstate
      'pushstate : color 1,1,.5 : move 4 : print c : popstate
      printl ""
    end macro
    '
    'pr "Action Code:   ", str(act)
    pr "Picked ID:     ", str(picked)
    pr "Keyboard Code: ", str(keyd)
    popstate
  end if

  '-- cube one gold 
  cls 0.0, 0.2, 0.7
  shading
  scale 1
  pushstate
    Material Gold
    UserMovement m4,400
    scale 1
    move -9,-2 
    static float ang
    rotateX ang
    rotateY 90+ang
    scale 1,3,4
    move -4.5,-1.75
    go cube
    scale 0.5,1
    rotateY 270+ang
    move -1.5,-1.75
    print "goody "
  popstate
 
  '-- cube two white rotating
  cls 0.0, 0.2, 0.7
  shading
  pushstate
    Material white
    UserMovement m5,500
    scale 3
    gltranslatef x,y,z
    x=-x '++
    static float ang
    rotateX ang'ang+x+1
    rotateY ang
    'rotateZ ang
    scale 0.35,1.25,1.5
    move 3,-1
    go cube
  popstate
  ang+=.5 : if ang>=360 then ang-=360

'cube3 -------------- // enemy
  shading
  scale 1
  pushstate
    Material red
    UserMovement m6,600
    scale 1
    move 1,-1 
    static float ang
    rotateX ang
    rotateY 90+ang
    scale 0.5,1.5,2
    go cube
    scale 0.5,1
    rotateY 270+ang
    move -1.5,-1.75
    print "evil "
  popstate

'------ bouncing cube 4 without gravity ------------ //
shading
  scale 1
  pushstate
    Material silver
    UserMovement m7,700
  'bouncing cube from right to left side
  glPushMatrix
  'static single va=10000,yp=4.00,yv=.00, ya=.004
  static single va=10000,yp=14.00,yv=.00, ya=.004
  yv-=ya 'acceleration
  yp+=yv
  if yp<0
    yv=-yv''*.9 'bounce with energy loss
    if yv<ya
      yv=0 'limit rebound
    else
      va*=.9
      'ding sqr(va),35 'vol 10..127 : percussion 35..81
    end if
    yp=0
  end if
  glscalef 2.5,2.5,2.5
  'glTranslatef 2.5,-1.5+yp,-6.0
  'glTranslatef 2.5+yp,-1.5,-6.0
  move -4.5+yp,1.5,-4.0
  'glScalef      .35,.35,.35
  Material redshiny 'silver
  scale 0.35
  go cube
  popstate

'
'-- mouse movement is too fast and not very smooth
'
'------------------ left little cube m8 --------------- //
'
  static single ang1,angi1=-2,angi2=1
  static float ang,ang2
  float s1,s2,s3,s4
      's1=.2
      's2=-1
      's3=0.5
      's4=s3*.2
      s1=.4
      s2=-2
      s3=1.5
      s4=s3*.4
 
  move -4,2
  pushstate
  Material BlueShiny
  UserMovement m8,800
  scale 6.5
   
      glbegin GL_QUADS
      glcolor4f   s3,   0,  s4, 1
      glvertex3f -s1, -s1,  s2

      glcolor4f    0,  s3,  s4, 1
      glvertex3f -s1,  s1,  s2

      glcolor4f   s4,   0,  s3, 1
      glvertex3f  s1,  s1,  s2

      glcolor4f   s3,   0,  s4, 1
      glvertex3f  s1, -s1,  s2
      glend
      move -0.5,-0.75
      scale 0.5
      print "goody2 "
      popstate
sleep 15
'------------------------------------------------ //
  end sub 'main

  EndScript

Nice evening and good start on monday Charles
#8
OxygenBasic Examples / Re: Moving objects opengl
Last post by Charles Pegge - February 25, 2024, 10:07:36 PM
Similar fixes for example 2. Ensure the UserMovement comes before scale
#9
OxygenBasic Examples / Re: Moving objects opengl
Last post by Charles Pegge - February 25, 2024, 09:45:13 PM
Hi Frank,

correction to your first example:

placement of scale 3 after UserMovement
  '-- cube two white rotating
  cls 0.0, 0.2, 0.7
  shading
  pushstate
    Material white
    UserMovement m5,500
scale 3
    gltranslatef x,y,z
    x=-x '++
    static float ang
    rotateX ang'ang+x+1
    rotateY ang
    'rotateZ ang
    scale 0.35,1.25,1.5
    move 3,-1
    go cube
  popstate
#10
OxygenBasic Examples / Re: Moving objects opengl
Last post by Frank Brübach - February 25, 2024, 09:21:33 PM
I have Made a Second example more Clean the Scene with moving objects and Quads..

Something is wrong with usermovement m5 gl_quads with Mouse movement its too fast ... Key Up right left down are OK


 '-- test openGL oxygen
 '-- moveable text and objects part two, frank bruebach
 '-- 24-25/02/2024
 
 #compact
 % Title "ConsoleG Demo:  Move text with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
  '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  $filename "t.exe"
 'uses RTL64
  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  sub main
  ========

  'WaitForEvent '0 off 1 on (default on)
  static int  z, y, x
  static quad t1,t2,t3
  if opening then 'FIRST CALL ONLY
    timemark t1
    picked=100
    'mbox "helo"
  end if
  '
  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    'exit sub
  end if
  cls
  pushstate
  color 1,.5,0,1
  UserMovement m1,100 'identity in steps of 100
  scale 2, 3
  print "Hello "
  popstate
  move 5

  pushstate
  color 1,1,0,1
  UserMovement m2,200
  scale 4
  print "World"
  popstate

  if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'kypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    macro pr(a,b) 'PRINTING LIST
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 8 : print b : popstate
      printl ""
    end macro
    '
  'pr "Action Code:  ", str(act)
    pr "Picked ID:    ", str(picked)
    pr "Keyboard Code: ", str(keyd)
    popstate
  end if

  cls 0.0, 0.2, 0.7
  shading
  scale 1 '3
  move 1,-4
  pushstate
    Material Gold
    UserMovement m3,300
    static float ang
    rotateX 'ang
    rotateY 'ang
    scale 1,3,4
    go cube
  popstate
  'ang+=.5 : if ang>=360 then ang-=360

'--------------------------------- //
'
  scale 2 '3
  move -4,-2
  pushstate
 
      UserMovement m4,400
' -- Creates quads, shapes with 4 vertices
      glbegin GL_QUADS
        glcolor4f  1,0,0,1    ' 255 -- Red color       
        glvertex3f -1, -1,  0
       
        glcolor4f  0, 1,  0,1    ' -- Green color               
        glvertex3f  1, -1,  0
               
        glcolor4f  0,  0, 1,1    ' -- Blue color                       
        glvertex3f  1,  1,  0       
       
        glcolor4f 1, 1, 0,1      ' -- Yellow color                               
        glvertex3f -1,  1,  0               
      glend
popstate

'------------------ left little cube --------------- //
'
  static single ang1,angi1=-2,angi2=1
  static float ang,ang2
  float s1,s2,s3,s4
      's1=.2
      's2=-1
      's3=0.5
      's4=s3*.2
      s1=.4
      s2=-2
      s3=1.5
      s4=s3*.4

  scale 2.5
  move -3,2
  pushstate
  Material Gold
  UserMovement m5,500
     
      glbegin GL_QUADS
      glcolor4f  s3,  0,  s4, 1
      glvertex3f -s1, -s1,  s2

      glcolor4f    0,  s3,  s4, 1
      glvertex3f -s1,  s1,  s2

      glcolor4f  s4,  0,  s3, 1
      glvertex3f  s1,  s1,  s2

      glcolor4f  s3,  0,  s4, 1
      glvertex3f  s1, -s1,  s2
      glend
      popstate
 
  sleep 15
  end sub 'main

  EndScript