Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - matchy

#1
Help! When I try to run a test program on RaspberryPi now I get this error:

Code (glbasic) Select

timer
rbow
rbow init
VSync unsupported on old SDL versions (before 1.2.10).
sdl init video RaspberryPi
pi goes fullscreen 720x480
./pitest.bin: symbol lookup error: ./pitest.bin: undefined symbol: glMatrixMode
#3
Normally, it's fine even unfocused but how can I capture the screen when the server program is running minimized or perhaps even as a console?



#4
On Linux/RPi, how can I fast pass an array (not command args nor serial) from a running GLBasic program to a running cpp (compiled with g++)?  :'( :S
#5
Although I've attempted unsuccessfully many times to, I decided to try out 3D carefully on the Raspberry Pi 2 again and gladly discovered that it works very well this time. The problems that I encountered was X_ROTATION only caused the crash (segmentation fault or sometimes bus error). Also, SIN and COS are not working so I easily replaced that with QSIN/QCOS, to rotate the camera around the object. Ambient light work 95% but some flickering from scene rotation but spotlights don't work. Test file attached.

;) 8)

#6
There's self. but how can I reference nested type referencing?   :-[
Logically, should there be parent. also?   :zzz:

Nested TYPE Example:
Code (glbasic) Select

TYPE _item
    id
    selected_id
    color
    size
    FUNCTION set:
         self.id = basket.item_id                    // absolute
//      self.id = parent.parent.item_id       // would prefer relative         
    ENDFUNCTION
ENDTYPE

TYPE _group
    apple AS _item
    banana AS _item
ENDTYPE

TYPE _base
    item_id
    fruit AS _group
ENDTYPE

GLOBAL basket as _base
basket.fruit.apple.set()

#7
Beta Tests / Bouldery(dash)
2015-Oct-22
So here's another game, a Boulderdash type, that I get near to completion, well at least the goal was for functionality so that it just now needs some design and art.  :whistle:  Any suggestions for what the players could be? perhaps erico might like to help me complete this game so it looks presentable and fun.  :P

#8
I'm presume a Android smart watch is just a smaller screen. I'm not so sure about them so I wonder would GLBasic compile for it?  :zzz:
#9
GLBasic - en / JSON parser?
2014-Nov-19
Has anyone posted or created a json parser?  :whistle:
#10
I'm trying to create a wireframe for 3D array of vertices with just X_LINE output (no X_GETMATRIX or X_GETFACES input) although I can't seem to get it right. Any suggestion why this classic function isn't right as the object is skewed at certain angles but okay near the perpendicular? :'(
Code (glbasic) Select

FUNCTION rotation AS _point: ob AS _obj, v AS _point
LOCAL p AS _point
p = v
INC p.x, v.x
INC p.y, (COS(ob.angle.x) * v.y) - (SIN(ob.angle.x) * v.z)
INC p.z, (SIN(ob.angle.x) * v.y) - (COS(ob.angle.x) * v.z)

INC p.x, (SIN(ob.angle.y) * p.z) + (COS(ob.angle.y) * p.x)
INC p.y, v.y
INC p.z, (COS(ob.angle.y) * p.z) - (SIN(ob.angle.y) * p.x)

INC p.x, (COS(ob.angle.z) * p.x) - (SIN(ob.angle.z) * p.y)
INC p.y, (SIN(ob.angle.z) * p.x) + (COS(ob.angle.z) * p.y)
INC p.z, v.z
RETURN p
ENDFUNCTION

FUNCTION wire: ob AS _obj
IF self.mouse.b1
ob.rotate.x = self.mouse.y_axis
ob.rotate.y = self.mouse.x_axis
INC ob.angle.x, ob.rotate.x
INC ob.angle.y, ob.rotate.y
ENDIF
LOCAL e AS _point
LOCAL f AS _point
FOR i = 0 TO ob.vertices - 2
ALIAS v AS ob.ver[i]
ALIAS u AS ob.ver[i + 1]
e = self.rotation(ob, v)
f = self.rotation(ob, u)
X_LINE  e.x, e.y, e.z,  f.x, f.y, f.z,  1, 0xffffff // v.color.value
NEXT
ENDFUNCTION

#11
Off Topic / 3D printed logo
2014-Oct-25
 :whistle:
#12
Code Snippets / Gamepad Test
2014-Aug-10
So I finally got a USB PC/Linux gamepad for the first time, a Logitech F310.  :enc: =D
It's cool and works well, so I had to write a test tool and included some compensation trimming as I noticed that the left and right, x & y axis of the analog sticks don't spring back to center sometimes (eg. 0.05 at worst).  ::) I'm not sure if this is hardware or software as the springy z triggers always return to zero.  :P

I was hoping to use it on Adnroid but when I test it only returns the accelerometers.

Code (GLBasic) Select

// --------------------------------- //
// Project: Game Pad Test
// Start: Sunday, August 10, 2014
// IDE Version: 12.096

TYPE _font
num
width
height
ENDTYPE

TYPE _sprite
num
width
height
ENDTYPE

TYPE _screen
width
height
width2
height2
backcolor
font AS _font
sprite_id

FUNCTION init:
SETSCREEN 800, 600, 0
GETSCREENSIZE self.width, self.height
self.width2 = self.width / 2
self.height2 = self.height / 2
self.backcolor = 0x000000
self.font.num = GENFONT()
LOCAL file$ = "Media/font.png" // make a font file!
IF DOESFILEEXIST(file$)
LOADFONT file$, self.font.num
SETFONT self.font.num
ENDIF
GETFONTSIZE self.font.width, self.font.height
ENDFUNCTION
ENDTYPE

TYPE _joy
a = 0
b = 1
x = 2
y = 3
lb = 4
rb = 5
back = 6
start = 7
l = 8
r = 9

jx = 0
jy = 1
jz = 2
rx = 3
ry = 4
rz = 5
dx = 6
dy = 7

count
stick[] AS _stick

FUNCTION init:
self.count = GETNUMJOYSTICKS() - 1
IF self.count > -1
DIM self.stick[self.count + 1]
FOR i = 0 TO self.count
self.stick[i].id = i
DIM self.stick[i].button[32]
DIM self.stick[i].control[8]
FOR j = 0 TO 31
SELECT j
CASE joy.a
self.stick[i].button[j].name$ = "A (Green)"
CASE joy.b
self.stick[i].button[j].name$ = "B (Red)"
CASE joy.x
self.stick[i].button[j].name$ = "X (Blue)"
CASE joy.y
self.stick[i].button[j].name$ = "Y (Yellow)"
CASE joy.lb
self.stick[i].button[j].name$ = "Left Top"
CASE joy.rb
self.stick[i].button[j].name$ = "Right Top"
CASE joy.back
self.stick[i].button[j].name$ = "Back"
CASE joy.start
self.stick[i].button[j].name$ = "Start"
CASE joy.l
self.stick[i].button[j].name$ = "Left Joy"
CASE joy.r
self.stick[i].button[j].name$ = "Right Joy"
DEFAULT
self.stick[i].button[j].name$ = "?"
ENDSELECT
NEXT
FOR j = 0 TO 7
SELECT j
CASE joy.jx
self.stick[i].control[j].name$ = "Left Joy X"
CASE joy.jy
self.stick[i].control[j].name$ = "Left Joy Y"
CASE joy.jz
self.stick[i].control[j].name$ = "Left Joy Z"
CASE joy.rx
self.stick[i].control[j].name$ = "Right Joy X"
CASE joy.ry
self.stick[i].control[j].name$ = "Right Joy Y"
CASE joy.rz
self.stick[i].control[j].name$ = "Right Joy Z"
CASE joy.dx
self.stick[i].control[j].name$ = "Pad X"
CASE joy.dy
self.stick[i].control[j].name$ = "Pad Y"
DEFAULT
self.stick[i].control[j].name$ = "?"
ENDSELECT
NEXT
NEXT
ENDIF
ENDFUNCTION

FUNCTION show:
WHILE TRUE
IF self.count > -1
// FOREACH js IN joy.stick[]
self.stick[0].update()
self.stick[0].view()
// NEXT
ELSE
PRINT "No joystick found. Connect one and restart!", 0, 0
self.init()
ENDIF
SHOWSCREEN
WEND
ENDFUNCTION
ENDTYPE

TYPE _button
value
name$
press
last_value
ENDTYPE

TYPE _stick
id
trm = 0.055
control[] AS _button
button[] AS _button

FUNCTION trim:
LOCAL val
FOR i = 0 TO 5
val = self.control[i].value
IF (val < 0 AND val > -self.trm) OR (val > 0 AND val < self.trm)
val = 0.0
ENDIF
IF val = 0.0
self.control[i].value = 0.0
self.control[i].press = 0
ELSE
INC self.control[i].press
ENDIF
self.control[i].value = val
NEXT
ENDFUNCTION

FUNCTION update:
self.control[joy.jx].value = GETJOYX(self.id)
self.control[joy.jy].value = GETJOYY(self.id)
self.control[joy.jz].value = GETJOYZ(self.id)
self.control[joy.rx].value = GETJOYRX(self.id)
self.control[joy.ry].value = GETJOYRY(self.id)
self.control[joy.rz].value = GETJOYRZ(self.id)
self.control[joy.dx].value = GETDIGIX(self.id)
self.control[joy.dy].value = GETDIGIY(self.id)
FOR i = 0 TO 31
self.button[i].value = GETJOYBUTTON(self.id, i)
IF self.button[i].value <> 0
INC self.button[i].press
ELSE
self.button[i].press = 0
ENDIF
NEXT
trim()
ENDFUNCTION

FUNCTION view:
LOCAL x = 0, h = screen.font.height, y = 0, c
FOR i = 0 TO 7
IF self.control[i].value <> 0
c = 0x00ff00
ELSE
c = 0x000022
ENDIF
x = screen.width * 0.05
DRAWRECT x - h, (i * h), h - 1, h - 1, c
PRINT self.control[i].name$ + ":", x, i * h
x = screen.width * 0.3
PRINT FORMAT$(3, 3, self.control[i].value), x, i * h
x = screen.width * 0.435
PRINT self.control[i].press, x, i * h
NEXT
FOR i = 0 TO 15 //31
IF self.button[i].value <> 0
c = 0x00ff00
ELSE
c = 0x000022
ENDIF
x = screen.width * 0.55
DRAWRECT x - h, (i * h), h - 1, h - 1, c
PRINT self.button[i].name$ + ":", x, i * h
x = screen.width * 0.8
PRINT self.button[i].value,   x, i * h
x = screen.width * 0.88
PRINT self.button[i].press,   x, i * h
NEXT
plot()
ENDFUNCTION

FUNCTION plot:
LOCAL jx = self.control[joy.jx].value
LOCAL jy = self.control[joy.jy].value
LOCAL jz = self.control[joy.jz].value
LOCAL rx = self.control[joy.rx].value
LOCAL ry = self.control[joy.ry].value
LOCAL rz = self.control[joy.rz].value
LOCAL s = (10 * jz) + 20, t = (s / 2)
DRAWRECT (jx * screen.width2) + screen.width2 - t, (jy * screen.height2) + screen.height2 - t, s, s, 0x00ffff
DRAWRECT (rx * screen.width2) + screen.width2 - t, (ry * screen.height2) + screen.height2 - t, s, s, 0xffff00
ENDFUNCTION
ENDTYPE

GLOBAL screen AS _screen
GLOBAL joy AS _joy
screen.init()
joy.init()
joy.show()
#13
It's a simple query but I am really wondering if there is a way to set the texture brightness for a 3d object, preferable without lighting objects in the scene. Much like ALPHAMODE but without the opaqueness. I'm not sure if ALPHATESTING can do it or X_SETCELSHADES then with lights if I have to.  :-[
#14
I think we all are still trying to design our great teenage minded game.  :whistle:



Before discovering Blitz Basic, I remember going in to the software store to get a game only to find an interesting application called Klik & Play.  :P
#15
I test on Cubietruck and Radxa Rock Android with a desktop keyboard. The KEY() command only works for some keys. I'd like to use WASD but not all work but the arrow keys do.   :blink:

Is this a bug or is there another method?
#16
I'm wondering what are the data type replacements for these parameters, which are used in Arduino C;
IMPORT uint32_t get_color(byte r, byte g, byte b)
How do you import this function:?  :bed:
Code (glbasic) Select

uint32_t Color(byte r, byte g, byte b) {
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}

#17
Here is a simply constructed http web server but I can only get one request. Sock closes and listens again, on another sock id, but not accepting the next one. Help!?  :-[

Update: solved - works okay now.

Code (glbasic) Select

// --------------------------------- //
// Project: webservermin
// Start: Sunday, May 26, 2013
// IDE Version: 10.283 / 11.414

TYPE _net
num = 0
ok = 0
accept = -1
listen = 0
ip% = 0
sock = 0
port = 80
rv = 0
length = 2048
msg$ = 0
ENDTYPE

TYPE _bug
x
y
log$[]
FUNCTION out: msg$
DEBUG msg$ + "\n"
ENDFUNCTION
ENDTYPE

GLOBAL net AS _net
GLOBAL bug AS _bug

loop()

FUNCTION loop:
AUTOPAUSE FALSE
ALLOWESCAPE TRUE
SYSTEMPOINTER TRUE
setup_webserver()
WHILE TRUE
CLEARSCREEN
loop_webserver()
SHOWSCREEN
WEND
ENDFUNCTION

FUNCTION setup_webserver:
net.ok = SOCK_INIT()
net.listen = SOCK_TCPLISTEN(net.port)
bug.out("net.listen:" + net.listen)
ENDFUNCTION

FUNCTION loop_webserver:
IF net.accept = -1
net.accept = SOCK_TCPACCEPT(net.listen, net.ip)
IF net.accept <> -1
bug.out("net.accept:" + net.accept)
ENDIF
ELSE
net.rv = SOCK_RECV(net.accept, net.msg$, net.length)
IF net.rv > 0
parse_html()
ENDIF
IF net.rv = -2
net.msg$ = "<html><body>Hello World!</body></html>"
net.ok = SOCK_TCPSEND(net.accept, net.msg$)
net.rv = SOCK_CLOSE(net.accept)
bug.out("net.rv:" + net.rv)
net.accept = -1
///// net.listen = SOCK_TCPLISTEN(net.port)   //// no need to relisten - solved
bug.out("net.listen:" + net.listen)
ENDIF
ENDIF
ENDFUNCTION

FUNCTION parse_html:
bug.out("msg:" + net.msg$)
LOCAL arr$[]
LOCAL i = SPLITSTR(net.msg$, arr$[], " ")
bug.out("arr$[1]:" + arr$[1])
ENDFUNCTION
[code=glbasic]
#18
Announcements / RPi and GPIO
2013-May-23
Although it would be nice to import direct, the simplest way I could access the GPIO on RaspberryPi was to use the GPIO Utility from wiringPi via SHELLCMD. This can mode set and write to the pins, for at least LED test, but doesn't seem to return the pin read value from the command line (0 or 1) for a button/joystick. Values can be saved to a data file for slower inputs. Anyhow, here's a mini-lib to start off for now.

gpio.gbas
Code (glbasic) Select

// --------------------------------- //
// Project: gpio - glb led/button sample
// Start: Thursday, May 23, 2013
// IDE Version: 11.414

GLOBAL PIN_LED = 4 // GPIO 23
GLOBAL PIN_BUTTON = 0 // GPIO 17

GLOBAL led_state = 0
GLOBAL button_state = 0
GLOBAL app_timer = 0


setup()
loop()

FUNCTION setup:
gpio.init()
gpio.pinMode(PIN_BUTTON, P_UP)
gpio.pinMode(PIN_LED, P_OUT)
ENDFUNCTION

FUNCTION loop_led:
IF led_state = 0
led_state = 1
gpio.digitalWrite(PIN_LED, HIGH);
ELSE
led_state = 0
gpio.digitalWrite(PIN_LED, LOW);
ENDIF
ENDFUNCTION

FUNCTION loop_draw:
LOCAL x = (50 * led_state)
DRAWRECT x, 0, 50, 50, 0xffffff
x = (50 * button_state)
DRAWRECT x, 50, 50, 50, 0xffffff
ENDFUNCTION

FUNCTION loop:
LOCAL ti = 0
WHILE ti < 10 AND TRUE
CLEARSCREEN 0x00ff00
INC app_timer
IF app_timer = 10
app_timer = 0
loop_led()
INC ti
button_state = gpio.digitalRead(PIN_BUTTON) // :(
ENDIF
loop_draw()
PRINT ti, 0, 110
PRINT app_timer, 50, 110
SHOWSCREEN
WEND
ENDFUNCTION


lib_gpio.gbas
Code (glbasic) Select

// --------------------------------- //
// Project: matchy_gpio_lib
// RaspberryPi wiringPi GPIO Utility: http://wiringpi.com/the-gpio-utility/
// Start: Thursday, May 23, 2013
// IDE Version: 11.414

GLOBAL P_IN = 0
GLOBAL P_OUT = 1
GLOBAL P_UP = 2
GLOBAL P_DOWN = 3
GLOBAL P_PWM = 4
GLOBAL P_TRI = 5
GLOBAL P_CLOCK = 6

GLOBAL LOW = 0
GLOBAL HIGH = 1

GLOBAL mode_name$[]

GLOBAL gpio AS _gpio

TYPE _gpio
FUNCTION digitalRead#: pin_num
RETURN gpio_cmd("gpio read " + pin_num) // :(
ENDFUNCTION

FUNCTION digitalWrite: pin_num, pin_val
gpio_cmd("gpio write " + pin_num + " " + pin_val)
ENDFUNCTION

FUNCTION pinMode: pin_num, pin_mode
gpio_cmd("gpio mode " + pin_num + " " + mode_name$[pin_mode])
ENDFUNCTION

FUNCTION gpio_cmd#: cmd$
LOCAL rv#, ok
// ?IF WIN32
// DEBUG cmd$ + "\n"
// ?ELSE
ok = SHELLCMD(cmd$, TRUE, TRUE, rv#)
// ?ENDIF
// RETURN INTEGER(rv)
RETURN rv# // :(
ENDFUNCTION

FUNCTION init:
DIM mode_name$[7]

mode_name$[P_IN] = "in"
mode_name$[P_OUT] = "out"
mode_name$[P_UP] = "in"
mode_name$[P_DOWN] = "down"
mode_name$[P_PWM] = "pwm"
mode_name$[P_TRI] = "in"
mode_name$[P_CLOCK] = "clock"
ENDFUNCTION
ENDTYPE

8)
#19
On what can be used to achieve perfect timing, like a metronome? I've tried various way with GETTIMERALL delay and SIN(GETTIMERALL()) bounce, sleep, limitfps and it's fine on PC but not on other "slower" devices.  :S
#20
As I can do this in 3dsmax, I was wondering if there is any snippets or libs for mesh compounding/subtracting.  :-[ For example, a cube is half way in a sphere and then, from two meshes, one new mesh is created with the subtracted vertices inside each model, or one model adds vertices in replace of the "cookie" bite subtraction from the other model.