Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] I'm having trouble adapting

Author
Message
SomeOldDude
1
Years of Service
User Offline
Joined: 21st May 2022
Location:
Posted: 21st May 2022 03:26
I first got into TGC back around 2008 with their DarkBASIC software. Loved it. Used two versions of it up until very recently. I bought a new computer and wanted the latest and greatest from TGC. They don't seem to offer DB anymore, but I got their AppGameKit Studio which appears to be 95% of what DB used to be plus new features that allow you to create apps/games for phones. Excellent! Many of the commands seem to have been overhauled to accommodate these features. I get that. But I'm having problems and I'm wondering if I'm not understanding some of the changes.

Example:
I'm just trying to get a hold of camera commands. I copied this from one of the examples:


do
If GetPointerState()
Camera_Angle_X# = GetCameraAngleX(1) + ((GetPointerY()-OldPointerY#)*0.5)
Camera_Angle_Y# = GetCameraAngleY(1) + ((GetPointerX()-OldPointerX#)*0.5)
if Camera_Angle_X# < -90 then Camera_Angle_X# = -90
if Camera_Angle_X# > 90 then Camera_Angle_X# = 90
SetCameraRotation(1,Camera_Angle_X#,Camera_Angle_Y#,0)
endif
OldPointerX# = GetPointerX()
OldPointerY# = GetPointerY()
Sync()
loop


... And it works. I looked up the GetPointerState() command and I understand that it's a general way for the program to acknowledge a "pointer" whether or not it's the mouse on a PC or a finger pointing on a phone. But if I try to modify the commands and tailor it to a PC by specifying that I'm on a PC...


do
If GetRawMouseLeftPressed()
Camera_Angle_X# = GetCameraAngleX(1) + ((GetPointerY()-OldPointerY#)*0.5)
Camera_Angle_Y# = GetCameraAngleY(1) + ((GetPointerX()-OldPointerX#)*0.5)
if Camera_Angle_X# < -90 then Camera_Angle_X# = -90
if Camera_Angle_X# > 90 then Camera_Angle_X# = 90
SetCameraRotation(1,Camera_Angle_X#,Camera_Angle_Y#,0)
endif
OldPointerX# = GetPointerX()
OldPointerY# = GetPointerY()
Sync()
loop


... the program runs, but the camera does not move when I press the left mouse button even though it worked fine with the GetPointerState() command. What am I missing? Why doesn't this work? And what's even more strange is that if I say "If GetRawMouseLeftPressed() then end" it works; the program ends when I click the mouse. So I know I'm using the command/syntax right. I've even tried saying "If GetRawMouseLeftPressed() = 1..." and there's no change. Am I wrong in believing that something that would've worked back in DB should work here? (Although, technically the old DB command would've been "if mouseclick() = 1...) I'm just getting frustrated with it and I'm beginning to wonder if I should just try to install my old DB software on my new computer, but I'd really like to get familiar with AppGameKit.

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st May 2022 10:14
Did you intend for the Camera to be 3D?
It looks like your using 2D co-ordinates to try move a 3D camera.
If you want to move the 2D camera try SetViewOffset()
Otherwise you'll need to translate the 2D co-ordinates to 3D space.
SomeOldDude
1
Years of Service
User Offline
Joined: 21st May 2022
Location:
Posted: 21st May 2022 13:20
(Looking back over the code)... Yeah, I can see how it looks like a 2D/3D clash. But that isn't my problem. Really I'm having a mouse input problem. I was really wondering what the difference was between GetPointerState() and GetRawMouseLeftPressed() that made one work and another not.

I continued tinkering with it last night, and I may have learned something: the GetPointerState() seems to be always tracking whether the left mouse button is pressed as the do/loop recycles, but the GetRawMouseLeftPressed seems to detect a single click and then stops even when the loop starts over. (Again, DB wouldn't have done that as far as I remember.) Really what I want is for this loop to be triggered by holding the middle mouse button. The GetPointerState seems to stipulate that the left mouse button be pressed, so naturally I went to the GetRawMouseMiddlePressed, but I couldn't get the left, right, or middle to work like I wanted. Is there any way to make this loop continue to run just by holding the middle mouse button? (Because I'm planning on using the left and right to actually move the camera forward and back.)
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 21st May 2022 21:38 Edited at: 21st May 2022 21:42
This post has been marked by the post author as the answer.
Yes, it's just a different command. You want to use:

GetRawMouseLeftState()

This provides a continuous return of the state of the mouse button, rather than just a click and release. You can use these additional commands for other button indexes:

GetRawMouseLeftState()
GetRawMouseRightState()
GetRawMouseMiddleState()
GetRawMouseFourthState()
GetRawMouseFifthState()
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 22nd May 2022 02:08 Edited at: 22nd May 2022 02:09
Pressed is for Detecting the Initial Event (i.e. When First Clicked)
We can use this in conjunction with Released for detecting when the input is no longer being Held
i.e.

SomeOldDude
1
Years of Service
User Offline
Joined: 21st May 2022
Location:
Posted: 23rd May 2022 23:49
Thank you, SFSW and Raven!! I feel a little dumb now, I checked the command library and the "getmousestate" commands were listed. But yeah, I'm coming over from the old DarkBASIC commands. This new software seems to be extremely similar, but perhaps there are some habits that I'm gonna have to break if I want to get good with it. I will say that the biggest change seems to be that the old Matrix commands are gone in favor of the "createobjectfromheightmap" function(s).

Login to post a reply

Server time is: 2024-04-26 23:14:26
Your offset time is: 2024-04-26 23:14:26