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 - shadok85

#1
Beta Tests / Poker Game
2011-Mar-02
Hi there!
I just completed my first small game. It's a variation of the poker game (five card draw poker), common in places like casinos. Currently, a system of doubling your winnings is missing, and the graphics is far from be jaw-dropping. I hope you like it. Feel free to storm me with feedback, criticism and bug reports! =D



[attachment deleted by admin]
#2
Off Topic / Birthday
2011-Feb-13
Am I wrong, or I and Gernot were born on the same day (February, the 13th)? Is it so? Happy birthday Gernot! :good:
#3
Hi all!
I have a problem with the RND function (or SEEDRND, perhaps): whenever I want a random numbers, I pick always the same sequence of digits. Example:

Code (glbasic) Select

LIMITFPS 60
SEEDRND GETTIMERALL()

LOCAL nums%[]
DIM nums%[6]

FOR i=0 TO 5
nums[i] = 1 + RND(90)
NEXT

WHILE TRUE
CLEARSCREEN

IF KEY(57)
FOR i=0 TO 5
nums[i] = 1 + RND(90)
NEXT
ENDIF

FOR i=0 TO 5
PRINT nums[i], 0, i*8
NEXT

SHOWSCREEN
SLEEP 100
WEND


Check by yourself. On the first run, you will got always 39, 9, 15, 20, 71, 14. Why?
#4
Hello,
I was trying to make a little pong demo, just for fun. Here is the code:

File Pong.gbas

Code (glbasic) Select

LIMITFPS 60

GLOBAL mx%, my%, ma%, mb%
GLOBAL screenW%, screenH%

GETSCREENSIZE screenW%, screenH%

LOCAL player AS TPaddle
LOCAL opponent AS TPaddle

LOCAL centerPaddle% = (screenH%/2) - (paddleHeight% / 2)

player.init(24, centerPaddle%, FALSE, FALSE)
opponent.init(screenW-24-paddleWidth%, centerPaddle%, FALSE, TRUE)

//////////////
// main loop

WHILE TRUE
CLEARSCREEN

player.update()
player.render()
opponent.update()
opponent.render()
renderFPS()

SHOWSCREEN
WEND

//////////////
// render FPS

FUNCTION renderFPS:
GLOBAL dtime%
GLOBAL fps%

dtime = GETTIMER()
fps = ((1000/dtime)+fps)/2

PRINT "FPS: " + FORMAT$(3, 0, fps), 0, 0
ENDFUNCTION


File Types.gbas

Code (glbasic) Select

GLOBAL mx%, my%, ma%, mb%
GLOBAL screenW%, screenH%

CONSTANT verticalLimit% = 20
CONSTANT paddleWidth% = 40
CONSTANT paddleHeight% = 100
CONSTANT mouseSensibility = 1.5

TYPE TPaddle
x%
y%
isComputer%
isOpponent%

FUNCTION init: x%, y%, isComputer%, isOpponent%
self.x% = x%
self.y% = y%
self.isComputer% = isComputer%
self.isOpponent% = isOpponent%
ENDFUNCTION

FUNCTION render:
DRAWRECT self.x%, self.y%, paddleWidth%, paddleHeight%, RGB(255,255,255)
ENDFUNCTION

FUNCTION update:
IF NOT self.isComputer%

MOUSESTATE mx%, my%, ma%, mb%

IF NOT self.isOpponent%
self.y% = self.y% + MOUSEAXIS(1) * mouseSensibility
ELSE
self.y% = self.y% - MOUSEAXIS(1) * mouseSensibility
ENDIF

IF self.y% > screenH% - paddleHeight% - verticalLimit%
self.y% = screenH% - paddleHeight%- verticalLimit%
ENDIF

IF self.y% < verticalLimit%
self.y% = verticalLimit%
ENDIF

SETMOUSE mx%, self.y%
ENDIF
ENDFUNCTION
ENDTYPE


The two paddles are controlled by mouse. The weird thing is this: when I try to move the mouse back and forth, the paddles move accordingly to it, but after a while, the movements start to limp. Sometimes I run the demo from the IDE, source unmodified, and the paddles don't move at all! Where is the problem??
#5
Hi there,
I'm new to GLBasic and, for learning purpose, I'm converting a BlitzMax sample into GLB. I have 2 files in the project:

Main Document (ComeAndGetMe.gbas):

Code (glbasic) Select

LOCAL UPDATE_FREQUENCY# = 100
LOCAL SPIKE_SUPPRESSION% = 20

GLOBAL gameTime AS TFRLTimer
gameTime.TFRLTimer_init(UPDATE_FREQUENCY#, SPIKE_SUPPRESSION%)

// the main loop starts here
WHILE TRUE
CLEARSCREEN

code...

SHOWSCREEN
WEND



and the TFRLTimer.gbas file which is:

Code (glbasic) Select

//==============================================================
//===FIXED RATE LOGIC  TWEEN  DELTA SPIKE SUPPRESSION (DSS)===
//==============================================================

TYPE TFRLTimer
newTime#
oldTime#
delta#

dssOn% // do we use delta spike suppression?
dssIndex% // index into DSS_Array where NEXT delta value is written
dssArray#[] // this array contains the delta values TO smooth
dssLenArray%         // how big is the array of delta values

logicFPS#
accumulator#
tween#

fpsAccumulator#
updateCount%
renderCount%
updatesPerSecond%
rendersPerSecond%

FUNCTION TFRLTimer_init: logicCyclesPerSec#, numSamples% = 0
self.logicFPS# = 1.0 / logicCyclesPerSec#
IF numSamples%
self.dssOn% = TRUE
DIM self.dssArray#[numSamples%]
self.dssLenArray# = numSamples%
ENDIF
ENDFUNCTION

FUNCTION TFRLTimer_processTime#:
self.newTime# = GETTIMERALL()
self.delta# = (self.newTime# - self.oldTime#) * 0.001
self.oldTime# = self.newTime#

IF self.dssOn% = TRUE
self.dssArray[self.dssIndex%] = self.delta#

LOCAL smoothDelta# = 0

FOR i% = 0 TO self.dssLenArray% - 1
smoothDelta# = smoothDelta# + self.dssArray[i%]
NEXT
self.delta# = smoothDelta# / self.dssLenArray%

self.dssIndex% = self.dssIndex% + 1
IF self.dssIndex% > self.dssLenArray% - 1 THEN self.dssIndex% = 0
ENDIF

self.accumulator# = self.accumulator# + self.delta#

self.fpsAccumulator# = self.fpsAccumulator# + self.delta#
IF self.fpsAccumulator# > 1.0
self.fpsAccumulator# = self.fpsAccumulator# - 1.0
self.updatesPerSecond% = self.updateCount%
self.updateCount% = 0
self.rendersPerSecond% = self.renderCount%
self.renderCount% = 0
ENDIF

RETURN self.delta#
ENDFUNCTION


FUNCTION TFRLTimer_logicUpdateRequired%:
IF self.accumulator# > self.logicFPS#
self.updateCount% = self.updateCount% + 1
self.accumulator# = self.accumulator# - self.logicFPS#
RETURN TRUE
ENDIF
RETURN FALSE
ENDFUNCTION


FUNCTION TFRLTimer_getLogicFPS#:
RETURN self.logicFPS#
ENDFUNCTION


FUNCTION TFRLTimer_getTween#:
self.renderCount% = self.renderCount% +1
RETURN self.accumulator# / self.logicFPS#
ENDFUNCTION


FUNCTION TFRLTimer_showSpikeSuppression: x%, y%
PRINT "Delta Spike Suppressor:", x%, y%
FOR i% = 0 TO self.dssLenArray% - 1
PRINT self.dssArray%[i%], x%, y% + (i% + 1) * 20
NEXT
PRINT "Final Delta: " + self.delta#, x%, y% + (self.dssLenArray% + 1) * 20
ENDFUNCTION


FUNCTION TFRLTimer_showFPS: x%, y%, showUpdateFPS% = TRUE, showRenderFPS% = TRUE
LOCAL ty% = y%

IF showUpdateFPS
PRINT "Logic FPS:  " + self.updatesPerSecond%, x%, ty%
ty% = ty% + 20
ENDIF
IF showRenderFPS
PRINT "Render FPS: " + self.rendersPerSecond%, x%, ty%
ENDIF
ENDFUNCTION
ENDTYPE



When I compile the project, I got this error:

_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.6.973 SN:90c38d47 - 3D, NET
"ComeGetMe.gbas"(0) warning : note : TYPE TFRLTimer is not declared

"ComeGetMe.gbas"(5) error : call to undefined function : TFRLTimer

and I can't really get why I got this error! I use the beta version of GLB (8.036). Please help me!

Thanks all, Mimmo