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.


Topics - Dark Schneider

Pages: 1 [2] 3
16
It could be like:
found% = FIND$(where$, find$, positions%[])
then use found% if you only are interested about if is contained, and positions%[] are the indexes (first char position in where$ of any appearance of find$) in the string if you need them.

Currently we only have INSTR() that only searches for the 1st one.

17
With OS X Lion on the market, we see that Lion is only compatible with XCode 4, then I'd like to know if the project generated by GLBasic is compatible with XCode 4 and there is no problem at all using it.

Thinking about upgrading the Mac  =D

18
The idea is to identify old versions of iPhone/iTouch to set the LIMITFPS 30 on them and 60 on newer ones. Old iDevices have really no speed at all and they are not able to run almost any game at 60 FPS.

Have someone tested if this works?
http://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-iphone-sdk

So for iPhone1,1 and iPod1,1 we'd use 30 FPS and 60 FPS otherwise.

19
Bug Reports / Warnings CPU_SUBTYPE_ARM_ALL
« on: 2011-Jun-30 »
This is not really a bug, when compiling for iOS, the new iOS SDK gives many (hundreds in a complex project) warnings of type CPU_SUBTYPE_ARM_ALL deprecated. It woud be great if GLBasic was updated to use the new definition, becasue so many warnings difficults to find real warnings.
The other reason is because usually the state after deprecated is obsolete (maybe in iOS 5 SDK?), and then this will be errors not warnings.

20
GLBasic - en / iPad screen at 640x960?
« on: 2011-Mar-24 »
Adjusting all the graphics only by a few pixels...is possible to set the project resolution to Retina for using on iPad?, how is it drawn? (margins, stretch?).

21
The problem is that in the XCode project the Debug config points to a Missing SDK if using some new XCode, surely because it points to 3.x version, while the Release config points to the Lastest one. It is easy to fix only changing by hand the config (Targets->iPhone->properties->Build, at the beginning). But if this could be fixed when GLBASIC generates the XCode project file, then better.

22
Code Snippets / iPhone AutoLock function
« on: 2011-Mar-24 »
I am sure this can be useful to many, it is typical in pro games to disable the iPhone autolock while you are playing, if not you are required to touch the screen, and it can affect how your app is used (forced touchs).

For use it, simply add the iOSAuxFunc.gbas to your GLBASIC project, and the iOSAuxFunc.m to your XCode project, for example to the Other Sources folder.

Included in the iOSAuxFunc is the EnableAutoLock() function, pass FALSE to disable it and TRUE to enable it again. There is no need to call EnableAutoLock(TRUE) on exit because the iOS devices do it by its own. The typical use is:

- Do not call at beginning.
- Call EnableAutoLock(FALSE) at start of GAMEPLAY.
- If paused, call EnableAutoLock(TRUE). When return to game call EnableAutoLock(FALSE).
- When gameplay ends (return to main menu, etc.), call EnableAutoLock(TRUE).

As summary, set AutoLock = OFF ( EnableAutoLock(FALSE) ) ONLY while playing, is the way iPhone games does it mainly.

[attachment deleted by admin]

23
Sometimes using FOREACH with a TYPE generates this error, i.e. I have this code:
Code: (glbasic) [Select]
FOREACH bonus_item IN stage.bonus_items[]
NEXT
This generates an error TYPE is not declared, but if I change it to:
Code: (glbasic) [Select]
FOR i%=0 TO LEN(stage.bonus_items[])-1
NEXT
exactly in the same place of code, it works fine.

I think the problem is accessing other TYPEs members using FOREACH, but in GLBASIC v8 this worked fine. I mark the "others" because using within a type with something like:
Code: (glbasic) [Select]
FOREACH bonus IN self.bonus_items[]
NEXT
works fine too.

24
Math / Vector 2D
« on: 2011-Jan-18 »
Typical case of 2D-Vector, very usefull for sprites and other 2D things:

Code: (glbasic) [Select]
// --------------------------------- //
// TYPE TVector2
// --------------------------------- //

CONSTANT TVector2VersionMajor%=1, TVector2VersionMinor%=1, TVector2VersionBuild%=0, TVector2VersionRevision%=2

//! TVector2
//!
//! Author: Dark Schneider
//!
//! Two-dimensional vector


//---------------------//
// --- DEFINITIONS --- //
//---------------------//


//---------------//
// --- TYPES --- //
//---------------//
//! TVector2 types

//! Type TVector2
//! Main type
TYPE TVector2

//---------------//
// - VARIABLES - //
//---------------//
x#=0
y#=0


//---------------//
// - FUNCTIONS - //
//---------------//
//! TVector2 functions

//! Set type data
//\param x# - coordinate X
//\param y# - coordinate Y
//\return Itself with new values
FUNCTION Set AS TVector2: x#=0, y#=0
self.x=x; self.y=y
RETURN self
ENDFUNCTION


//\return Length squared of vector
FUNCTION LengthSq:
RETURN self.x*self.x+self.y*self.y
ENDFUNCTION


//\return Length of vector
FUNCTION Length:
RETURN SQR(self.x*self.x+self.y*self.y)
ENDFUNCTION


//\param v - vector for dot product
//\return Dot product of itself with v
FUNCTION DotProduct: v AS TVector2
RETURN self.x*v.x+self.y*v.y
ENDFUNCTION


//\param scale# - scale factor
//\return Itself scaled
FUNCTION Scale AS TVector2: scale#
self.x=self.x*scale#
self.y=self.y*scale#
RETURN self
ENDFUNCTION


//\return Itself normalized
FUNCTION Normalize AS TVector2:
LOCAL l#=self.Length()
IF l < 0.0000001
self.Set(0,0)
ELSE
self.Scale(1.0/l)
ENDIF
RETURN self
ENDFUNCTION


//\return Itself with inverse values: x=-x; y=-y
FUNCTION Invert AS TVector2:
self.x=-self.x
self.y=-self.y
RETURN self
ENDFUNCTION


//\return New vector with inverse values: x=-x; y=-y
FUNCTION Inverse AS TVector2:
LOCAL l_result AS TVector2
l_result=self
l_result.Invert()
RETURN l_result
ENDFUNCTION


//\param v - vector to add
//\return Itself modified
FUNCTION Add AS TVector2: v AS TVector2
self.x=self.x+v.x
self.y=self.y+v.y
RETURN self
ENDFUNCTION


//\param v - vector to substract
//\return Itself modified
FUNCTION Substract AS TVector2: v AS TVector2
self.x=self.x-v.x
self.y=self.y-v.y
RETURN self
ENDFUNCTION


//! Compute angle between the vector and another one
//\param v - vector against to compute angle
//\return Angle from itself to v, values in the range [0-180[
FUNCTION AngleWith: v AS TVector2
LOCAL div#, dot#
div = self.Length() * v.Length()
IF div = 0 THEN RETURN 0
dot = self.DotProduct(v) / div
IF ABS(dot) > 1 THEN RETURN 0 // 1.5/1.49999
RETURN ACOS(dot)
ENDFUNCTION


//\return Angle of the vector using X axis as angle=0
FUNCTION ToAngle:
LOCAL l_result#=0
IF self.x<>0 AND self.y<>0
l_result=ATAN(self.y,self.x)
IF self.y<0 THEN l_result=360+l_result
ELSE
IF self.x=0
IF self.y>0
l_result=90
ELSEIF self.y<0
l_result=270
ENDIF
ELSEIF self.y=0 AND self.x<0
l_result=180
ENDIF
ENDIF
RETURN l_result
ENDFUNCTION


//! Modify the vector creating a normalized vector with direction defined by an angle
//\return Itself modified
FUNCTION FromAngle AS TVector2: angle#
self.x=COS(angle)
self.y=SIN(angle)
RETURN self
ENDFUNCTION

ENDTYPE



//-------------------//
// --- FUNCTIONS --- //
//-------------------//
//! Global functions

//! Create a new vector instance
//\param x# - coordinate X
//\param y# - coordinate Y
//\return The new vector instance
FUNCTION TVector2Create AS TVector2: x#=0, y#=0
LOCAL l_result AS TVector2
l_result.Set(x,y)
RETURN l_result
ENDFUNCTION


//! Add 2 vectors
//\param v1 - vector1
//\param v2 - vector2
//\return New vector v=v1+v2
FUNCTION TVector2Add AS TVector2: v1 AS TVector2, v2 AS TVector2
LOCAL l_result AS TVector2
l_result=v1
l_result.Add(v2)
RETURN l_result
ENDFUNCTION


//! Substract 2 vectors
//\param v1 - vector1
//\param v2 - vector2
//\return New vector v=v1-v2
FUNCTION TVector2Substract AS TVector2: v1 AS TVector2, v2 AS TVector2
LOCAL l_result AS TVector2
l_result=v1
l_result.Substract(v2)
RETURN l_result
ENDFUNCTION


//! Scale a vector
//\param v - vector to use as base for scale
//\scale# - scale factor
//\return New vector v*scale
FUNCTION TVector2Scale AS TVector2: v AS TVector2, scale#
LOCAL l_result AS TVector2
l_result=v
l_result.Scale(scale#)
RETURN l_result
ENDFUNCTION


//! Compute a normalized vector with direction defined by an angle
//\return New vector
FUNCTION TVector2FromAngle AS TVector2: angle#
LOCAL l_result AS TVector2
l_result.FromAngle(angle)
RETURN l_result
ENDFUNCTION


//! Computes the linear interpolation between 2 vectors
//\param v1 - vector1
//\param v2 - vector2
//\param interpolation# - interpolation value, [0.0-1.0]
//\return Vector with values of the interpolation
FUNCTION TVector2LinearInterpolation AS TVector2: v1 AS TVector2, v2 AS TVector2, interpolation#
LOCAL l_vresult AS TVector2
l_vresult.x=(1.0-interpolation)*v1.x+interpolation*v2.x
l_vresult.y=(1.0-interpolation)*v1.y+interpolation*v2.y
RETURN l_vresult
ENDFUNCTION

25
If not set the %, is the FPU used in any way, affecting the performance or not?
example:
Code: (glbasic) [Select]
FUNCTION MyFunc:
   LOCAL result%
   ...
   return result
endfunction

We return an integer but we have not set the % on the function, is the value changed to FP?.

What about if we return nothing?

On PC this is not noticeable, but this can be important on devices, where we have only a shared vector unit for FP computing and its power is very limited. Especially when we have function that are called many times per franme, like TYPES.Update()

26
I have this error including if I compile a new empty project, it only fails when compiling for iPhone, many other targets (GP2X-WIZ, GP2X, Xbox-Linux) compiles with no error.

With an empty project, I have this:

Code: (glbasic) [Select]
_______________________________________
*** Configuration: IPHONE ***
precompiling:
GPC - GLBasic Precompiler V.8.142 SN:74167187 - 3D, NET
Wordcount:0 commands
compiling:
arch:
/cygdrive/q/Compiler/platform/iPhone/bin/arm-apple-darwin9-libtool: object: gpc_tempg.o truncated or malformed object (offset field of section 2 in LC_SEGMENT command 0 extends past the end of the file)
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 4.2 sec. Time: 13:16
Build: 0 succeeded.
*** 1 FAILED ***

I think my compiler is up to date, it doesn't detect any new version.

Any ideas?

27
I think it is an interesting feature, but I don't know if there is currently a way to do this on GLBasic.

28
Hello, I'd like to know about this, something like a fast tutorial. How it works exactly?.

In example, for a project in landscape mode, we set 1024x768, then at begin we do GETSCREENSIZE?. What coordinates report MOUSESTATE?, and for drawing, we need to set the appropiated (x,y) scaled values?, we need to load the correct media or we must use the method of "@2x"?.

Thanks.

29
The original is here, with the example project:
http://gamecorner.110mb.com/index.php?page=bitmap-fonts-proportional

I have modified it for these reasons:
- To work with my Screen Manager (http://www.glbasic.com/forum/index.php?topic=5439.0).
- Added a param, it is the lastest one, 'kernoffset', I saw it interesting, giving it a negative value we can have the highly desirable effect of slight overlap. Try it in the example of the project using this modified version and giving negative values to 'kernoffset'.

The credits was untouched as this is work of PeeJays with slighty modifications. Justify text doesn't work properly but this is a mistake in the original too. Remember to add the Screen Manager to work.

[attachment deleted by admin]

30
Code Snippets / Screen Manager
« on: 2010-Dec-16 »
Hi, here is a centralized screen manager for GLBasic (those ones that uses CREATESCREEN and USESCREEN), so we only need to ask for a screen with CreateScreen, use it with RenderBegin, ask for its sprite associated with GetSprite, and release them with Destroy, with no worry about if the screen requested is in use or not (CreateScreen always will give us a free one if available). Remember to destroy not more needed ones.

Code: (glbasic) [Select]
// --------------------------------- //
// TYPE ScreenManager
// --------------------------------- //

CONSTANT ScreenManagerVersionMajor%=1, ScreenManagerVersionMinor%=0, ScreenManagerVersionBuild%=0, ScreenManagerVersionRevision%=2

//! Screen Manager
//!
//! Author: Dark Schneider
//!
//! Management of SCREENS


//---------------------//
// --- DEFINITIONS --- //
//---------------------//


//-------------------//
// --- VARIABLES --- //
//-------------------//
GLOBAL ScreenManagerSprites%[], ScreenManagerSpritesCursor%=0


//-------------------//
// --- FUNCTIONS --- //
//-------------------//
//! FUNCTIONS

//! initializes the Screen Manager system, MUST be called ONLY ONCE before using it
FUNCTION ScreenManagerInit:
IF ScreenManagerIsInitialized() THEN ScreenManagerDispose()
DIM ScreenManagerSprites[32]
FOR i%=0 TO LEN(ScreenManagerSprites[])-1
ScreenManagerSprites[i]=-1
NEXT
ScreenManagerSpritesCursor=0
ENDFUNCTION


//! releases all the resources
FUNCTION ScreenManagerDispose:
ScreenManagerDestroyScreenAll()
DIM ScreenManagerSprites[0]
ENDFUNCTION


//! checks if the Screen Manager system has been initialized
// \return TRUE if the Screen Manager system has been initialized, FALSE if not
FUNCTION ScreenManagerIsInitialized:
IF LEN(ScreenManagerSprites[])>0 THEN RETURN TRUE
RETURN FALSE
ENDFUNCTION


//! screens iterator
// \return the next screen available, -1 if no available
@FUNCTION ScreenManagerNext:
LOCAL l_cursor%=ScreenManagerSpritesCursor
WHILE ScreenManagerSprites[ScreenManagerSpritesCursor]<>-1
INC ScreenManagerSpritesCursor
IF ScreenManagerSpritesCursor>=LEN(ScreenManagerSprites[]) THEN ScreenManagerSpritesCursor=0
IF ScreenManagerSpritesCursor=l_cursor THEN RETURN -1
WEND
RETURN ScreenManagerSpritesCursor
ENDFUNCTION


//! creates a new screen with parameters
// \param width% - width of the screen
// \param height% - height of the screen
// \return screen number, range 0-31, -1 if there is no screen available
FUNCTION ScreenManagerCreateScreenWithParams: width%, height%
LOCAL l_screen%=ScreenManagerNext()
IF l_screen=-1 THEN RETURN -1
ScreenManagerSprites[l_screen]=GENSPRITE(); CREATESCREEN l_screen, ScreenManagerSprites[l_screen], width, height
RETURN l_screen
ENDFUNCTION


//! creates a new screen with the screen resolution as size
// \return screen number, range 0-31, -1 if there is no screen available
FUNCTION ScreenManagerCreateScreen:
LOCAL scw%,sch%
GETSCREENSIZE scw,sch
RETURN ScreenManagerCreateScreenWithParams(scw,sch)
ENDFUNCTION


//! destroys a screen and releases the resources used
FUNCTION ScreenManagerDestroyScreen: screen_num%
IF ScreenManagerIsScreenInit(screen_num) THEN LOADSPRITE "xx", ScreenManagerSprites[screen_num]
ScreenManagerSprites[screen_num]=-1
ENDFUNCTION


//! destroys all the screens and releases the resources used
FUNCTION ScreenManagerDestroyScreenAll:
FOR i%=0 TO LEN(ScreenManagerSprites[])-1
ScreenManagerDestroyScreen(i)
NEXT
ENDFUNCTION


//! checks if an indicated screen has been created
// \param screen_num% - screen number to check
// \return TRUE if created, FALSE if not
FUNCTION ScreenManagerIsScreenInit: screen_num%
IF ScreenManagerSprites[screen_num]<>-1 THEN RETURN TRUE
RETURN FALSE
ENDFUNCTION


//! gets the sprite associated to a screen number
// \param screen_num% - screen number to check
// \return SPRITE ID associated to the screen, -1 if that screen has not been initialized
FUNCTION ScreenManagerGetSprite: screen_num%
RETURN ScreenManagerSprites[screen_num]
ENDFUNCTION


//! gets the size of the indicated screen
// \param screen_num% - screen number to check
// \param BYREF width% - return value of the screen width
// \param BYREF height% - return value of the screen height
FUNCTION ScreenManagerGetScreenSize: screen_num%, BYREF width%, BYREF height%
IF ScreenManagerIsScreenInit(screen_num)
GETSPRITESIZE ScreenManagerGetSprite(screen_num),width,height
RETURN TRUE
ELSE
width=-1; height=-1; RETURN FALSE
ENDIF
ENDFUNCTION


//! sets the indicated screen as render target
// \param screen_num% - screen number to check
// \return TRUE is success, FALSE if screen indicated has not been initialized
FUNCTION ScreenManagerRenderBegin: screen_num%
IF ScreenManagerIsScreenInit(screen_num)=FALSE THEN RETURN FALSE
USESCREEN screen_num
RETURN TRUE
ENDFUNCTION


//! sets the backbuffer as render target
FUNCTION ScreenManagerRenderEnd:
USESCREEN -1
ENDFUNCTION


Pages: 1 [2] 3