Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (VoroneTZ, dr_panther, TedMar, vicknick), 833 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
quick question #147723
08/13/07 20:16
08/13/07 20:16
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i am working on a recharge code and am useing morrowing as an example, i have the recharge and panels all working ok, and i wrote this bit of code as a small test, what should happen is the charge goes back to 0 and a sound should play, but neither happens, could someone point out were i`ve gone wrong please
Code:

function beam_weapons
{
if ((mouse_left == 1) && (player.phaser == 70))
{
player.phaser = 0;
snd_play (beam_wav, 50, 0);
}
}




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: quick question [Re: jigalypuff] #147724
08/13/07 22:09
08/13/07 22:09
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
well, the phasers energy has to be 70, guessing that player.phaser is the phasers energy. other than that i don't know. oh and try "on" instead of 1.

Last edited by Bot190; 08/13/07 22:12.

Wait, there isn't a "Make My Game Now" button?
Re: quick question [Re: Bot190] #147725
08/13/07 22:14
08/13/07 22:14
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
well ya but the phaser energy is up, that is all working ok, here`s the code for that.
Code:

panel Phaser_pan
{
bmap = charge_pan_tga;
pos_x = 945;
pos_y = 567;
window = 3, 2, 74, 7, charge_tga, player.phaser, 0; // can range from 0 to 74
flags = refresh, visible;
}

function init_player_startup()
{
while (player == null) {wait (1);}
player.phaser = 74;
while (1)
{
player.phaser += 0.4 * time; // increase power slowly
player.phaser = min(74, player.phaser); // limit phaser power 74
wait (1);
}
}


all this seems to work, and i assume at least the sound should play when i press the left mouse button.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: quick question [Re: jigalypuff] #147726
08/13/07 22:17
08/13/07 22:17
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
well the way your code is writen the player.phaser has to be at 70 no more no less... so if its at 74 it won't work. and obviusly you have to have the sound file in the same foler. try switching the mouse thing.

[Edit] you didn't call the function that checks if you pressed the mouse button... or is it called somewhere? [Edit]

Last edited by Bot190; 08/14/07 00:06.

Wait, there isn't a "Make My Game Now" button?
Re: quick question [Re: Bot190] #147727
08/14/07 01:15
08/14/07 01:15
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Yeah, your function is increasing player.phaser by a TIME factor which makes it incredibly unlikely that player.phaser will ever be exactly equal to 70. either use the int() function to only look at the integer value of player.phaser, or change the comparison in the if statement to something like

if(player.phaser > 68 && player.phaser < 72) { blah }

Re: quick question [Re: LogantheHogan] #147728
08/14/07 14:02
08/14/07 14:02
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i am useing on_mouse_left to activate the function.
logan i have tried what you suggested but it did not work, i suspect this is my fault though lol, how would you suggest i use the int() function? i don`t recall seeing that in the morrowing code at all.
here is what i tried.
Code:

function beam_weapons
{
if ((mouse_left == 1) && (player.phaser >68 && player.phaser <72))
{
player.phaser = 0;
snd_play (beam_wav, 50, 0);
}
}

on_mouse_left = beam_weapons;




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: quick question [Re: jigalypuff] #147729
08/14/07 15:36
08/14/07 15:36
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
maybe if((mouse_left == 1) && int(player.phaser) == 70) {}

but I'd use an easier thing just for testing, and just say if((mouse_left == 1) && player.phaser > 70){}. See if that works.

Also, like Bot said, I saw no reference to the beam_weapons function in the other code you posted. make sure you're calling it somewhere, or make sure it's running somehow. if you're not, that is your problem.

EDIT: never mind. I just saw your last post when you referenced on_mouse_left. So that's not the problem.

Last edited by LogantheHogan; 08/14/07 15:36.
Re: quick question [Re: LogantheHogan] #147730
08/14/07 15:42
08/14/07 15:42
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
woohoo cheers guys, it now works, any thoughts on how to get the energy to slowly deplete while the mouse button si pressed lol.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: quick question [Re: jigalypuff] #147731
08/14/07 19:04
08/14/07 19:04
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Code:

var phaser_decreasing = 0;

function init_player_startup()
{
while (player == null) {wait (1);}
player.phaser = 74;
while (1)
{
if(phaser_decreasing == off)
{
player.phaser += 0.4 * time_step; // increase power slowly
player.phaser = min(74, player.phaser); // limit phaser power 74
}
wait (1);
}
}

function beam_weapons
{
while ((mouse_left == 1))
{
phaser_decreasing = on;
player.phaser -= 3*time_step;
snd_play (beam_wav, 50, 0);
wait(1);
}
phaser_decreasing = off;
}

on_mouse_left = beam_weapons;



By the way, don't use the TIME variable anymore. It's kinda not stylish these days. use time_step instead. Use it in the exact same way, just a different name. I replaced your TIME variables in the functions above with time_step already.

Re: quick question [Re: LogantheHogan] #147732
08/14/07 21:57
08/14/07 21:57
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
that works with just one little problem, when the power has been decreased i can keep fireing, it needs to actually not be able t owork if there is no power.
thanks for your help.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Page 1 of 2 1 2

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