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

Messages - Amon

#1
Thank You!

Setting it to say 90 rotates the given axis by that amount. Using the mouse, how would I rotate my object by using phi? Is phi a -359 | 359 angled number?

#2
I'm at a loss as to what phi does and how to use X_ROTATION properly.

If I had a gun that moved according to MOUSESTATE and X_ROTATION how would I use phi with this? Here's some code:

Code (glbasic) Select

SETCURRENTDIR("Media") // go to media files

SETSCREEN 1024, 768, 0

GLOBAL GunM4 = 1
GLOBAL GunM4$ = "M4a1.ddd"
X_LOADOBJ GunM4$, GunM4
LOADSPRITE "M4a1.jpg", GunM4

WHILE NOT KEY(1)
X_MAKE3D 1, 5000, 45
LOCAL mx, my, b1, b2, rot#, mx2, my2
LOCAL gx, gy, gz
gx = 150
gy = -100
gz = -250

mx2 = MOUSEAXIS(0)
my2 = MOUSEAXIS(1)
MOUSESTATE mx, my, b1, b2

X_CAMERA 0, 20, -500, 0, 0, 0

X_DRAWAXES 0,0,0

X_MOVEMENT -50, -100, -250


IF mx <> 0
IF my <> 0
// IF mx > 360 THEN mx = 1
// IF mx < -360 THEN mx = -1
SETMOUSE mx, my
X_ROTATION , gx + -mx, gy + my, 0
ENDIF
ENDIF

X_SETTEXTURE GunM4, -1
X_DRAWOBJ GunM4, 0

SHOWSCREEN
WEND
#3
Thank You! I'll check out your code but it wasn't necassary at all to do all the work :)

I'm going to post my code so far as I've understood it from the docs when reading on types. I don't have the functions in a type, instead I passed the function by reference as in the docs.

This is plainly for my own learning of GLBasic so if it is all wrong please point out where it's noobing.

I do appreciate you converting the code though but before I read it I need to understand where I'm going wrong with my attempt, for learning purposes.

edit: Removed code; posting this mornings update.

I have it all compiling fine but what I'd like to do now is seperate the logic from the drawing by having the Draw function in the main loop and the Logic updating itself independant of the main loop.

Possible? Yes it is but first I must find all the ways that don't work in order to find what does and to do that I must code and learn. :) Help though would be appreciated.

Code (glbasic) Select

SETCURRENTDIR("Media")

GLOBAL BlueShip% = 0
LOADSPRITE "BlueShip.png", BlueShip
GLOBAL sx#, sy#
GETSPRITESIZE BlueShip, sx, sy

GLOBAL dw%, dh%
GETDESKTOPSIZE dw,dh

GLOBAL ESCAPEGAME% = 0

?IF WIN32
?DEFINE SCREENRES
?DEFINE STARTPOS
?ENDIF

?IF SCREENRES
LOCAL dww = 800, dwh = 600
SETSCREEN dww, dwh, 0
?ENDIF

?IF STARTPOS
GLOBAL BShipX# = (800.0 / 2.0) - sx / 2.0
GLOBAL BShipY# = 500.0
?ENDIF

GLOBAL dt AS DeltaTimer
dt.InitDelta()
dt.SetDeltaFPS(60.0)


REPEAT
dt.UpdateDelta()
CLEARSCREEN
Draw()
SHOWSCREEN
UNTIL ESCAPEGAME = 1

END


TYPE DeltaTimer
targetfps#
currentticks#
lastticks#
frametime#
delta#

FUNCTION InitDelta :
self.targetfps = 0.0
self.currentticks = 0.0
self.lastticks = 0.0
self.frametime = 0.0
self.delta = 0.0
RETURN TRUE
ENDFUNCTION

FUNCTION SetDeltaFPS : fps#
self.targetfps = fps
self.lastticks = GETTIMERALL()
RETURN fps
ENDFUNCTION

FUNCTION UpdateDelta :
self.currentticks = GETTIMERALL()
self.frametime = self.currentticks - self.lastticks
self.delta = self.frametime / (1000.0 / self.targetfps)
self.lastticks = self.currentticks
Logic()
RETURN TRUE
ENDFUNCTION

ENDTYPE

FUNCTION Logic:
IF KEY(203) AND NOT KEY(205) THEN BShipX = BShipX - 3.0 * dt.delta
IF KEY(205) AND NOT KEY(203) THEN BShipX = BShipX + 3.0 * dt.delta
ENDFUNCTION

FUNCTION Draw:
IF KEY(01) THEN ESCAPEGAME = 1
ALPHAMODE -1
DRAWSPRITE 0, BShipX, BShipY
ALPHAMODE 0
ENDFUNCTION
#4
I'm trying to convert some Mojo code to GLBasic but having a little difficulty. It seems to work but not as desired. The code is some simple custom Delta Timing code I used in Mojo. Code below:

Code (glbasic) Select


Import mojo

Class DeltaTimer

' Usage...

' 1) Create DeltaTimer object, eg.
' "Local dt:DeltaTimer = New DeltaTimer (60)"
' where 60 is your game's intended frame rate,
' regardless of device frame rate.

' 2) Call dt.UpdateDelta at start of OnUpdate...

' 3) Multiply all speeds by dt.delta...

' 4) That's it.

Field targetfps:Float = 60
Field currentticks:Float
Field lastticks:Float
Field frametime:Float
Field delta:Float

Method New (fps:Float)
targetfps = fps
lastticks = Millisecs
End

Method UpdateDelta ()
currentticks = Millisecs
frametime = currentticks - lastticks
delta = frametime / (1000.0 / targetfps)
lastticks = currentticks
End

End

Class Game Extends App

Global FPS:Int = 60

' Position/speed of example rects...

Field ux:Float = -16 ' Position increased by uncorrected speed
Field dx:Float = -16 ' Position increased by DELTA-CORRECTED speed
Field xs:Float = 4.0 ' Speed

Field dt:DeltaTimer ' A handle for the delta timer (to be created in OnCreate)

Method OnCreate ()
dt = New DeltaTimer ( FPS ) '  Gameplay update rate...
SetUpdateRate FPS ' ... may be different to device/app update rate!
End

Method OnUpdate ()

' ---------------------------------------------------------------------------
' 1) Get new frame delta...
' ---------------------------------------------------------------------------

dt.UpdateDelta

' ---------------------------------------------------------------------------
' 2) Multiply speeds by frame delta...
' ---------------------------------------------------------------------------

ux = ux + xs ' Speed NOT scaled by frame delta, ie. how NOT to do it...
dx = dx + xs * dt.delta ' Speed scaled by frame delta...

' Wrap rects around screen...

If ux > DeviceWidth + 16 Then ux = -16
If dx > DeviceWidth + 16 Then dx = -16

' Change FPS on the fly to see effect...

If KeyHit (KEY_LEFT)
FPS = FPS - 10
If FPS < 10 Then FPS = 10
SetUpdateRate FPS
Endif

If KeyHit (KEY_RIGHT)
FPS = FPS + 10
SetUpdateRate FPS
Endif

If KeyDown (KEY_ENTER)
FPS = 60
SetUpdateRate FPS
Endif

End

Method OnRender ()

Cls 32, 64, 128

DrawText "Time scale factor (Delta): " + dt.delta + " (Frame time: " + dt.frametime + " ms)", 0, 20

SetColor 255, 0, 0
DrawRect ux - 16, 200 - 16, 32, 32
SetColor 255, 255, 255
DrawText "Uncorrected", ux - 16, 200 - 32

SetColor 0, 255, 0
DrawRect dx - 16, 260 - 16, 32, 32
SetColor 255, 255, 255
DrawText "Corrected by delta timing", dx - 16, 260 - 32

DrawText "Use <- and -> plus ENTER to change game update rate (currently " + FPS + " fps)", 0, 60

End

End

Function Main ()
New Game
End


#6
Thank You Kitty but I get a 404 not found. :) Fix teh linky... :D
#7
Hi All! I'm using the beta and I checked for an update using the update feature; it downloads fine but when it goes to apply the update I get a crash and it closes. the update is the latest one for today. The crash, when I view debug info, points to MSVCR100.DLL.

Gonna try reinstalling VCRedist to see if it fixes it but if it doesn't some advice  would be appreciated, thanks.  :)
#8
Ahh, I went back to the same version as okee. Didn't realise it was that because after installing I moved whereit was stored in the path and when it worked I just assumed it was because I moved it.

Kind of a silly presumption but in my defence it was very late and GLBasic kept me awake....It's that good. :D :p
#9
Hi! I put C:\MinGW at the begining of the path and all seems to work fine for now. Will post again if any other problems come up.
#10
The contents of the path file had C:\MinGW\bin in it. 

QuoteC:\Program Files (x86)\ATI Stream\bin\x86_64;C:\Program Files (x86)\ATI Stream\bin\x86;%CommonProgramFiles%\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\MinGW\bin;C:\Applications\Coding\TortoiseSVN\bin;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\MinGW\bin

I'll try what Kitty says now. :)
#11
Ok, after a bit more messing about it now works properly. I had to completely remove any reference to MinGW i.e. Environment variables, anythign stored in "path" and a clean of the temp folder. After reboot it works fine.

Is there any way to be able to use GLbasic while MinGW is installed? It just seems a bit of a waste of time to have to keep adding MinGW to use blitzMax and removing it in order to use GLBasic.

#12
There's still no joy for me. It refuses to compile/build.

I have removed MinGW and reinstalled GLbasic but I get the same error. Sometimes the error doesn't even show in the console.

What is worng with it?
#13
Hi! Loading a normal file or any type of file now gives me the same error as okee. It deffo has something to do with MinGW.
#14
I have MinGW installed because it's needed by BlitzMax. As for error messages it doesn't bring up anything, no popup or console message other than Build 1 0 succeded.
#15
Hi I updated to the latest version and I can't seem to compile or build. Even if I put a simple while loop it just doesn't want to compile or build and rung the app?

Any ideas as to what could be wrong?