Merci les gars!
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
UNISCREEN_CREATE(400, 300) // Créé un écran de 400, 300 en s'adaptant à la taille et l'orientation du support utilisé (créé aussi un ecran virtuel de 400 sur 300).
UNISCREEN_SETSIZE(800, 600) // Redimensionne l'écran virtuelle à 800 sur 600
USESCREEN 0
// Draw blablabla...
UNISCREEN_SHOW()
// --------------------------------- //
// Project: UniScreen.gbas
// Start: Tuesday, May 15, 2012
// IDE Version: 10.283
// SETCURRENTDIR("Media") // go to media files
GLOBAL UNISCREEN_RX#, UNISCREEN_RY#
GLOBAL UNISCREEN_OUTW#, UNISCREEN_OUTH#
GLOBAL UNISCREEN_STRETCH = FALSE
FUNCTION UNISCREEN_SETSIZE: w#, h#
IF w >= h
UNISCREEN_RX = 1
UNISCREEN_RY = h / w
ELSE
UNISCREEN_RX = w / h
UNISCREEN_RY = 1
ENDIF
CREATESCREEN 0, 0, w, h
ENDFUNCTION
FUNCTION UNISCREEN_GETMOUSE: BYREF mx#, BYREF my#, BYREF lmb#, BYREF rmb#
LOCAL x#, y#, w#, h#, spw#, sph#
LOCAL _mx#, _my#, _lmb#, _rmb#
MOUSESTATE _mx, _my, _lmb, _rmb
IF UNISCREEN_STRETCH = FALSE
IF UNISCREEN_RX > UNISCREEN_RY
IF UNISCREEN_OUTW * UNISCREEN_RY > UNISCREEN_OUTH
w = UNISCREEN_OUTW * (UNISCREEN_OUTH / (UNISCREEN_OUTW * UNISCREEN_RY))
h = UNISCREEN_OUTH
ELSE
w = UNISCREEN_OUTW
h = UNISCREEN_OUTW * UNISCREEN_RY
ENDIF
ELSE
IF UNISCREEN_OUTH * UNISCREEN_RX > UNISCREEN_OUTW
w = UNISCREEN_OUTW
h = UNISCREEN_OUTH * (UNISCREEN_OUTW / (UNISCREEN_OUTH * UNISCREEN_RX))
ELSE
w = UNISCREEN_OUTH * UNISCREEN_RX
h = UNISCREEN_OUTH
ENDIF
ENDIF
x = (UNISCREEN_OUTW - w) / 2.0
y = (UNISCREEN_OUTH - h) / 2.0
ELSE
x = 0
y = 0
w = UNISCREEN_OUTW
h = UNISCREEN_OUTH
ENDIF
GETSPRITESIZE 0, spw, sph
mx = INTEGER((_mx - x) * (spw / w))
my = INTEGER((_my - y) * (sph / h))
lmb = _lmb
rmb = _rmb
ENDFUNCTION
FUNCTION UNISCREEN_CREATE: w#, h#, fullscreen#
LOCAL info$ = PLATFORMINFO$("DEVICE")
LOCAL desktopWidth#, desktopHeight#
LOCAL orientation% = 0
GETDESKTOPSIZE desktopWidth, desktopHeight
IF w >= h
UNISCREEN_RX = 1
UNISCREEN_RY = h / w
IF info$ <> "DESKTOP"
IF desktopWidth < desktopHeight
orientation = 1
UNISCREEN_OUTW = desktopHeight
UNISCREEN_OUTH = desktopWidth
ELSE
UNISCREEN_OUTW = desktopWidth
UNISCREEN_OUTH = desktopHeight
ENDIF
ELSE
UNISCREEN_OUTW = w
UNISCREEN_OUTH = h
ENDIF
ELSE
UNISCREEN_RX = w / h
UNISCREEN_RY = 1
IF info$ <> "DESKTOP"
IF desktopWidth > desktopHeight
orientation = 3
UNISCREEN_OUTW = desktopHeight
UNISCREEN_OUTH = desktopWidth
ELSE
UNISCREEN_OUTW = desktopWidth
UNISCREEN_OUTH = desktopHeight
ENDIF
ELSE
UNISCREEN_OUTW = w
UNISCREEN_OUTH = h
ENDIF
ENDIF
SETSCREEN UNISCREEN_OUTW, UNISCREEN_OUTH, fullscreen
SETORIENTATION orientation
CREATESCREEN 0, 0, w, h
ENDFUNCTION
FUNCTION UNISCREEN_COMPUTEVIEW: BYREF x, BYREF y, BYREF w, BYREF h
IF UNISCREEN_RX > UNISCREEN_RY
IF UNISCREEN_OUTW * UNISCREEN_RY > UNISCREEN_OUTH
w = UNISCREEN_OUTW * (UNISCREEN_OUTH / (UNISCREEN_OUTW * UNISCREEN_RY))
h = UNISCREEN_OUTH
ELSE
w = UNISCREEN_OUTW
h = UNISCREEN_OUTW * UNISCREEN_RY
ENDIF
ELSE
IF UNISCREEN_OUTH * UNISCREEN_RX > UNISCREEN_OUTW
w = UNISCREEN_OUTW
h = UNISCREEN_OUTH * (UNISCREEN_OUTW / (UNISCREEN_OUTH * UNISCREEN_RX))
ELSE
w = UNISCREEN_OUTH * UNISCREEN_RX
h = UNISCREEN_OUTH
ENDIF
ENDIF
x = (UNISCREEN_OUTW - w) / 2.0
y = (UNISCREEN_OUTH - h) / 2.0
ENDFUNCTION
FUNCTION UNISCREEN_SHOW:
LOCAL x#, y#, w#, h#
USESCREEN -1
IF UNISCREEN_STRETCH = FALSE
UNISCREEN_COMPUTEVIEW(x, y, w, h)
STRETCHSPRITE 0, x, y, w, h
ELSE
STRETCHSPRITE 0, 0, 0, UNISCREEN_OUTW, UNISCREEN_OUTH
ENDIF
SHOWSCREEN
// VIEWPORT x, y, -1, -1
ENDFUNCTION
GLOBAL waveLoops[] AS WAVELOOP
TYPE WAVELOOP
waveid
state
length
chn
mil
ENDTYPE
FUNCTION wlAdd: id, l
LOCAL wl AS WAVELOOP
wl.waveid = id
wl.length = l
wl.state = 0
wl.chn = 0
wl.mil = 0
DIMPUSH waveLoops[], wl
RETURN LEN(waveLoops) - 1
ENDFUNCTION
FUNCTION wlPlay: id
waveLoops[id].state = 1
waveLoops[id].chn = PLAYSOUND(waveLoops[id].waveid, 0, 1)
waveLoops[id].mil = GETTIMERALL() + waveLoops[id].length
ENDFUNCTION
FUNCTION wlUpdate:
LOCAL mil
FOREACH wl IN waveLoops[]
IF wl.state = 1
mil = GETTIMERALL()
IF mil >= wl.mil
wl.chn = PLAYSOUND(wl.waveid, 0, 1)
wl.mil = GETTIMERALL() + wl.length
ENDIF
ENDIF
NEXT
ENDFUNCTION
QuoteSounds was one of the biggest problems when developing this game. First i was using ApWidgets with multiple MediaPlayers. But later in process i find out that this was very laggy on some devices. After days of searching and studying i found way to use SoundPool and get contents from /data folder ( /assets after export ). AssetManager was the solution.
Music files was too big for the SoundPool, so i had to use MediaPlayer instead.
QuoteA JXD? Russian console?http://www.jxd.hk/download.asp?selectclassid=020001