small code problem

Non-platform specific questions.

small code problem

Postby Zehper48 » Sat Dec 22, 2007 9:02 pm

ok i have a problem with my code, here it is
Code: Select all
no1.textNumber = goalxpV - currentxpV /55;


ok, when i do this, my text number doesnt get divided by 55, it gets turned into a realy weird number
and goalxpV = 388 and currentxpV = 0 in this case,
what should i do differently? are there any obvious mistakes..


Thanks!
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: small code problem

Postby MrScience101 » Sat Dec 22, 2007 10:58 pm

Any way to post your code? It could be that the variables are integers, or there is simply a silly typo somewhere in the code. From the above statement, there is just not enough info to come to a good conlcusion.
User avatar
MrScience101
 
Posts: 115
Joined: Tue Mar 20, 2007 9:52 pm
Score: 13 Give a positive score

Re: small code problem

Postby Game A Gogo » Sun Dec 23, 2007 12:40 am

it gives out 7.05454545454... right?
well, let me tell ya why in a simple thing

388 - 0 /55
=(388-0)/55
=388/55

so you see, you need to do this

no1.textNumber=goalxpV-(currentxpV/55);
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: small code problem

Postby Zehper48 » Sun Dec 23, 2007 5:03 pm

i want it to give me 7.05454545454
but it gives me 388
some how in
no1V = goalxpV - currentxpV / 55; (i changed it to no1V which is a variable and i made no1.textNumber = to no1V)
the result of goalxpV - currentxpV isn't getting divided by 55

i dont know why, its confusing


*SUPER EDIT*
yay i found the problem!!! the problem was this
no1V =goalxpV - currentxpV / 55;

it should be no1V = (goalxpV - currentxpV) / 55; with the (,) to get the result!

i have to remeber Order of Operations =p

im happy now!

thx
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: small code problem

Postby Zehper48 » Sun Dec 30, 2007 7:57 am

This is kind of another problem, but i didnt want to make a new topic but heres my code
Code: Select all
if (findV==1)
{
    no1.textNumber = (goalxpV - currentxpV) / 55;
    no2.textNumber = (goalxpV - currentxpV) / 75;
    no3.textNumber =  0;
    no4.textNumber =  0;
    no5.textNumber =  0;
    no6.textNumber =  0;
    no7.textNumber =  0;
}

this is on a mouse down left event
so i added a tempory text number to see if "findV" equaled 1, and it did, and i did same for "goalxpV" and "currentxpV"
but still when i have a mouse down left on the actor that preforms this code, guess what happens to no1.textNumber-no7.textNumber? nothing happens

any obious mistakes?





. /^--^\ /^--^\ /^--^\
. \____/ \____/ \____/
. / \ / \ / \
. | | | | | |
. \__ __/ \__ __/ \__ __/
. |^|^|^|^|^|^|^|^|^|^|^\ \^|^|^/ /^|^|^|^\ \^|^|^|^|^|^|^|^|^|^|
. | | | | | | | | | | | |\ \| |/ /| | | | |\ \| | | | | | | | | |
. | | | | | | | | | | | |/ /| |\ \| | | | |/ /| | | | | | | | | |
. | | | | | | | | | | | |\/ | | \/| | | | |\/ | | | | | | | | | |
. ###############################################################
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: small code problem

Postby Sgt. Sparky » Wed Jan 02, 2008 2:20 am

Zehper48 wrote:This is kind of another problem, but i didnt want to make a new topic but heres my code
Code: Select all
if (findV==1)
{
    no1.textNumber = (goalxpV - currentxpV) / 55;
    no2.textNumber = (goalxpV - currentxpV) / 75;
    no3.textNumber =  0;
    no4.textNumber =  0;
    no5.textNumber =  0;
    no6.textNumber =  0;
    no7.textNumber =  0;
}

this is on a mouse down left event
so i added a tempory text number to see if "findV" equaled 1, and it did, and i did same for "goalxpV" and "currentxpV"
but still when i have a mouse down left on the actor that preforms this code, guess what happens to no1.textNumber-no7.textNumber? nothing happens

any obious mistakes?

I don't see any obvious problems with the code.
But why are you using 7 different actors to display variables?
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: small code problem

Postby Zehper48 » Wed Jan 02, 2008 6:36 am

the code is acctualy longer , finvV =1,2,3,4, all the way to 16.

for each number the no1-no7.textNumber equal somthing different... im rly confused, im just going to have to play around with it i guess,



****EDIT***** umm, i found out what was wrong but i feel rly stupid, i have a uhmm filled region in the way. dnt laugh, lol idont care if you laugh lol its pretty funny~
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: small code problem

Postby Sgt. Sparky » Wed Jan 02, 2008 6:54 pm

Zehper48 wrote:the code is acctualy longer , finvV =1,2,3,4, all the way to 16.

for each number the no1-no7.textNumber equal somthing different... im rly confused, im just going to have to play around with it i guess,



****EDIT***** umm, i found out what was wrong but i feel rly stupid, i have a uhmm filled region in the way. dnt laugh, lol idont care if you laugh lol its pretty funny~


*doesn't laugh* :)
Don't worry, I have done a whole lot of things like that before. xD
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron