Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Ayumi, Akow, AndrewAMD), 1,505 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple arithmetics not working? #186243
02/28/08 06:01
02/28/08 06:01
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I'm starting to experiment with the joy_rot/raw values, and I tried the example in the manual for keeping the throttle within a 0-100 range. Mathematically, it's perfect, but I can't seem to get it to work.

Here's the Code:

#include <acknex.h>
#include <default.c>

fixed throttle;

PANEL* _joydiag=
{
digits(512,364,"joyX= %1.0f",_a4font,1,joy_raw.x);
digits(512,384,"joyY= %1.0f",_a4font,1,joy_raw.y);
digits(512,404,"throttle= %1.0f",_a4font,1,throttle);
flags= VISIBLE;
}

void main()
{
video_mode= 8;
video_screen= 1;
screen_color.red= 1;
wait(3);
while(1)
{
throttle= 50 - (50 / 255) * joy_raw.z;
wait(1);
}
}



As you can see, it's a very simple test program that merely shows the values of the joystick axes. I don't understand why the red part is showing 50 instead of what the actual value should be.

Could it be an error elsewhere?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Simple arithmetics not working? [Re: MrCode] #186244
02/28/08 06:16
02/28/08 06:16
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
It probably means that your joystick is not registering the joy_raw.z values.
Is it showing changes in the x,y values ?
The code looks perfect to me.


I like good 'views' because they have no 'strings' attached..
Re: Simple arithmetics not working? [Re: MrCode] #186245
02/28/08 11:48
02/28/08 11:48
Joined: Feb 2008
Posts: 9
Germany, Cologne
dinosaur Offline
Newbie
dinosaur  Offline
Newbie

Joined: Feb 2008
Posts: 9
Germany, Cologne
Hi MrCode,

mathematically everything is ok.

But (50/255) is always = 0 because they are integers and will be rounded (0.19 = 0)

If you write (50.0/255.0) then it should work.

Regards
dinosaur

Re: Simple arithmetics not working? [Re: dinosaur] #186246
02/29/08 00:46
02/29/08 00:46
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
ok, everything seems to work now.

@Conitec: It would be great if you could implement the ability to use different data types for PANEL* items, instead of just fixed (var).


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1