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

#31
RIP
#32
Quote from: matchy on 2011-Oct-06
AMateus, I'm not sure what you mean because I use no 2D sprites nor any form of trickery, just texture sprite mapping in 3D.

To my knowledge, the Box2D wrapper doesn't have collision listeners implemented, so in GLB I'm unable to detect Box2D collisions. Normally the workaround is to have a sprite bigger than the physics body and detect the sprite collision before the physics collision and act accordingly.

If you don't use this trick, how do you know that a collision in Box2D has occurred to play the sound?

António
#33
@matchy do you use the "sprite bigger than physics body" trick?
#34
Nice :)

I will also try bit shifting (prototyping is a bliss lol) =)

Last night I give another shot at Box2D and was able to achieve the effect I want to (sort of). Now, if there was Collision Listeners ;)

Thanks,
António
#35
That was my intention but I had two problems (correct me if I'm wrong):

- The callbacks for collisions are not implemented

- Could not create bounding box for preventing the ball from leaving the screen (left and right - top and bottom I used create ground successfully)

So I give up and now I'm trying to implement it manually.

António
#36
Quote from: Crivens on 2011-Oct-04
Or just do the one collision and check the current location against the last ok one. Obvious then which way you are moving and can then respond accordingly.

Cheers

Not quite :) If are alway moving in 2 directions in a bouncing ball. So do you collide because you're falling or because you're falling left? ;)

Another solution is to break the ball in 4 sprites (up, down, left and right). But it could lead to a major fps drop, if you are testing 1 ball against 100 or so platforms. Slydog's option is probably the best on, even if I have to change the logic a bit eheh...

Thanks guys, for your help :)
António
#37
Quote from: Kitty Hello on 2011-Oct-04
ASCII 127 FTW!
I'll have a look, anyway.
What I will definitely do is, replace ó with o then, so don't expect your app to have an id: com.antónio.supergame

ROFTL

That's fine by me ;)
#38
Hello,

Another weird problem from me lol

I have a ball bouncing around and a platform. I would like to know in which side the ball collide to change the direction accordingly (could be left, right, top or bottom).

Currently the collision based on y is working fine. Problem is when the ball collides with the left or right side of the block. I've tried some ideas taken from chating, but I'm having some problems implementing it. And unfortunately SPRCOLL doesn't give any info about the collision =)

So, has anyone done this before or has some solution/idea?

Thanks,
António
#39
GLBasic - en / Re: EXP()
2011-Oct-04
oh ok thanks... my math sucks lol xD
#40
GLBasic - en / EXP()
2011-Oct-04
Hi,

Is there a way to calculate EXP(number) in GLBasic? I don't seem to find it in the manual. Is it implemented?

I have tried inline but give me errors on compile (not surprised here cause I'm not a C fellow =P).

Code (glbasic) Select

// Beginning of the module
INLINE

#include <math.h>
ENDINLINE


// and then the function
FUNCTION Exponential#: value#

INLINE

return exp (value);

ENDINLINE

ENDFUNCTION


When compiling the error is:
Code (glbasic) Select

C:\Users\ANTNIO~1\AppData\Local\Temp\glbasic\gpc_tempg.cpp: In member function `DGInt __GLBASIC__::tMath::Exponential(DGInt)':
C:\Users\ANTNIO~1\AppData\Local\Temp\glbasic\gpc_tempg.cpp:218: error: `exp' was not declared in this scope


Thanks,
António
#41
Well, one afternoon to find the solution... nevermind the 3 post above =)

António
#42
Some more info...

If I use the example with some commented lines (see bellow) I have compile errors:

Code (glbasic) Select

doSleep = TRUE

// Box
DRAWRECT 0,0,32,32,RGB(255,255,255)
GRABSPRITE 0, 0,0,32,32
CLEARSCREEN

DRAWRECT 0,0,320,32,RGB(0,100,255)
GRABSPRITE 1, 0,0,320,32
CLEARSCREEN

b_InitWorld(0,0, 640,480,  0.0, 10.0, doSleep)

//LOCAL box1%, ground%
//box1 = b_CreateBox(1, .2, .5, 301,20,32,32)
//box2 = b_CreateBox(1, 3.2,.5, 347,20,32,32)
//cir1 = b_CreateCircle(1,1,.5, 290,-10,25)
//ground = b_CreateGroundbox(323,300,320,32)
//
//
//DEBUG "box1 "+box1+"\n"
//DEBUG "box2 "+box2+"\n"
//DEBUG "cir1 "+cir1+"\n"
//DEBUG "gnd  "+ground+"\n"
//
//// a triangle
//LOCAL pts[]
//DIM pts[3][2]
// // polygon points (clockwise!!)
// //        x            y
// pts[0][0]=0; pts[0][1]=0
// pts[1][0]=20;pts[1][1]=15
// pts[2][0]=0; pts[2][1]=20
// b_CreatePoly( 1, 2.0, 0.5,  301,60, pts[])
//
//
//
//b_BodySetAngle(box1,47)
//
//b_BodySetAngle(box2,44)

WHILE TRUE
b_Update(0.1, 10)

// ROTOSPRITE 0, b_BodyGetPosX(box1)-16,    b_BodyGetPosY(box1)-16,   b_BodyGetAngle(box1)
// ROTOSPRITE 0, b_BodyGetPosX(box2)-16,    b_BodyGetPosY(box2)-16,   b_BodyGetAngle(box2)
// ROTOSPRITE 1, b_BodyGetPosX(ground)-160, b_BodyGetPosY(ground)-16, b_BodyGetAngle(ground)


b_WorldDebug() // debug a wireframe of what's happening
SHOWSCREEN
WEND




SUB GLB_ON_QUIT:
b_Cleanup()
ENDSUB


Really don't understand why. I only comment the drawing routines...
#43
Also, I'm no even using any command from the wrapper.. I've just add the file for future use  :blink:

I'm also doing some tests on the example and something is terribly wrong... sometimes compiles, sometimes don't. Even if I copy my files to the example project and run it sometimes has erros, sometimes don't.. I'm completly lost here... :|

my code for your review (I have a main file - this on -, the box2d wrapper, and a utils library, nothing more):

Code (glbasic) Select

GLOBAL SysInfo AS tSystemInfo // Current Platform Info
GLOBAL AppInfo AS tApplicationInfo // Application defined Info

GLOBAL sw%, sh% // Screen Resolution
GLOBAL aw%, ah% // Application defined resolution

GLOBAL lGameRunning // Indicates the game is running. If FALSE then go to the menu
GLOBAL iAppState // Indicates in what stage the application is: 1-Intro 2-Menu 3-Game

GLOBAL lDebug // Indicates if the application is in debugmode

GOSUB InitializeApplication

doSleep = TRUE

b_InitWorld(0,0, aw%,ah%,  0.0, 10.0, doSleep)

WHILE lGameRunning=TRUE

b_Update(0.1, 10)

IF lDebug THEN b_WorldDebug()

SHOWSCREEN
WEND

SUB GLB_ON_QUIT:
b_Cleanup()
ENDSUB

SUB InitializeApplication:

ALLOWESCAPE TRUE

SysInfo.GetCurrentResolution(sw%,sh%)
AppInfo.GetAppResolution(aw%,ah%)

lGameRunning = TRUE
iAppState = 1

lDebug=TRUE
ENDSUB

SUB CloseApplication:
ENDSUB


Inside the project dir I copied from the example the source dir, the documentation dir and the Box2D.h file.

Any help?!

Thanks,
AMateus
#44
Hello,

Doing some test with Box2D. Copied the Box2D.gbas, box2d.h and everything in the Source dir from the project in the first page. When compiling give me this error...

Code (glbasic) Select

C:\Users\ANTNIO~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp: In function `DGInt __GLBASIC__::b_CreatePoly(DGInt, DGInt, DGInt, DGInt, DGInt, __GLBASIC__::DGIntArray&)':
C:\Users\ANTNIO~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:492: error: no match for call to `(__GLBASIC__::DGIntArray) (int&, int)'
D:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:402: note: candidates are: DGInt& __GLBASIC__::DGIntArray::operator()(int)
D:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:442: note:                 __GLBASIC__::DGIntArray& __GLBASIC__::DGIntArray::operator()()
C:\Users\ANTNIO~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:492: error: no match for call to `(__GLBASIC__::DGIntArray) (int&, int)'
D:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:402: note: candidates are: DGInt& __GLBASIC__::DGIntArray::operator()(int)
D:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:442: note:                 __GLBASIC__::DGIntArray& __GLBASIC__::DGIntArray::operator()()
*** FATAL ERROR - Please post this output in the forum


If I run the project from the first page everything is ok.

Any ideias?

Thanks,
António
#45
I have android sdk working and the java_home environment variable has spaces =) go figure :P