Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Declaration name "

Author
Message
Shining Moonblade
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 20th Apr 2003 04:59
This is odd. I've been working on smooth manual animation of frames so I can take control of frame rates and such. I got 3 pieces of the animation working: idling, walking, and walking backwards.
After that I tried to implement some timer use to regulate when the animation would take place. (Idling at whatever fps you're getting is really funny looking.) When I did so, I started getting this error that:
Declaration name " is not valid on line 19.

All I'm doing on line 19 is declaring a variable. It looks like this:

global forward as integer = 1

This line was working without a hitch before I started using the timer use. So I deleted the timer use lines to see if that would fix the problem. I'm still getting the message.

First of all, how can it be saying I'm declaring " when I'm declaring forward?

And why won't the message disappear? I don't believe I've changed anything else in the code. Look at it here and tell me if it runs on your system:

rem Basic Init
hide mouse
autocam off
sync on: sync rate 60

rem Variable init
global plr as integer = 2
global numframes as integer = 25
global idle as integer = 0
global walking as integer = 1
global walkingback as integer = 2
global attacking as integer = 3
global dying as integer = 4
global forward as integer = 1
global backwards as integer = (-1)
global True = 1
global False = 0
global timecount as integer = 0


rem Character type Init
type chardata
mving as integer
curmving as integer
curendframe as integer
frstep as integer
x as integer
y as integer
z as integer
height as integer
idleframe as integer
moveframe as integer
attackframe as integer
dieframe as integer
totalframes as integer
currentframe as integer
endtype

rem Create our player data and add some defaults
char as chardata
char.mving = idle
char.curmving = idle
char.currentframe = 1

rem Load our model and add the keyframe numbers
load object "Ninja-Idle.x", plr
char.idleframe = 1

append object "Ninja-Move.x", plr, total object frames(plr) + 1
char.moveframe = total object frames(plr) - numframes

append object "Ninja-Attack.x", plr, total object frames(plr) + 1
char.attackframe = total object frames(plr) - char.moveframe + 1

append object "Ninja-Die.x", plr, total object frames(plr) + 1
char.dieframe = total object frames(plr) - char.attackframe + 1

scale object plr, 300, 300, 300
set object speed plr, 40

char.totalframes = total object frames(plr)
char.height = object size y(plr)

rem Make a basic landscape
make matrix 1, 5000, 5000, 25, 25
position matrix 1, 0, 0, 0

load image "sandstone.bmp", 1
prepare matrix texture 1, 1, 1, 1

position object plr, 2500, (char.height / 2), 2500
char.x = object position x(plr)
char.y = object position y(plr)
char.z = object position z(plr)

position camera 2500, char.height, 2510
rem position camera char.x, 20, char.z
point camera char.x, (char.height / 2), char.z


set object frame plr, char.currentframe

rem Our Main Loop -----------------------------------------------

do

rem timecount = timer()
char.x = object position x(plr)
char.y = object position y(plr)
char.z = object position z(plr)
char.curmving = char.mving

rem Find out what motion we're going to be taking
if scancode() = 0 then char.mving = idle
if upkey() = 1 then char.mving = walking
if downkey() = 1 then char.mving = walkingback
rem if leftkey() = 1 then turn object left plr, 3
rem if rightkey() = 1 then turn object right plr, 3
if shiftkey() = 1 then char.mving = attacking
if controlkey() = 1 then char.mving = dying
if leftkey() = 1
turn object left plr, 3
endif
if rightkey() = 1
turn object right plr, 3
endif

rem char.mving = walkingback

rem Now let's start animating

Animate()


rem Print Data
set cursor 0, 0
print screen fps()
print " "
print "Char.x: "; char.x
print "Char.y: "; char.y
print "Char.z: "; char.z
print " "
print "Char.height: "; char.height
print "Obj Size Y: "; object size y(plr)
print " "
print "Object Frame: "; object frame(plr)
print "Char.currentframe: "; char.currentframe
print "Char.mving: "; char.mving
print "Char.curmving: "; char.curmving
print "Char.frstep: "; char.frstep
print " "
print scancode()
print " "
print idle
print walking
print walkingback
print attacking
print dying


rem Draw the screen
sync

rem Suspend for key so we can see things step by step
rem suspend for key

loop

rem -------------------------------------------------------------

function Animate

rem This function basically splits up the animation process
rem down into small pieces and sets them on their way.

rem If we want to sit still then,
if char.mving = idle
AnimIdle()
endif


rem If we want to walk
if char.mving = walking
AnimWalk()
endif

rem Do we want to walk backwards?
if char.mving = walkingback
AnimWalkBack()
endif

endfunction

Function AnimIdle

rem Are doing something else?
if char.mving = char.curmving

rem Then go to the next frame
char.frstep = forward
char.currentframe = char.currentframe + char.frstep

rem Check to make sure we'll loop if we're still idle
if char.currentframe > char.moveframe - 1
char.currentframe = 1
endif

rem Position our character
set object frame plr, char.currentframe
else
if char.curmving = walking or char.curmving = walkingback
if char.currentframe = char.moveframe + 4
set object frame plr, char.moveframe + 2
else
set object frame plr, char.moveframe + 4
endif
endif
endif

endfunction

function AnimWalk

rem Are we doing something else?
if char.mving = char.curmving
rem To the next frame!
char.frstep = forward
char.currentframe = char.currentframe + char.frstep

remstart
Walking is a little different because the animation
frames don't fully sync into a step. So we have to
cycle through from char.movestep + 6 to
char.attackframe - 1 to walk right
remend

rem Check to make sure we'll loop
if char.currentframe > char.attackframe - 1
char.currentframe = char.moveframe + 6
endif

rem Position our character
set object frame plr, char.currentframe
else
if char.curmving = idle
char.currentframe = char.moveframe
endif
endif

endfunction

function AnimWalkBack

rem Are we doing something else?
if char.mving = char.curmving

remstart
Walking backwards is more fun because the frames
can get goofy on us. So I'll have to do some manual
control.
remend
if char.currentframe
The moon empowers my blade and commands me to destroy you all!
Shining Moonblade
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 20th Apr 2003 05:01
? Well that didn't work. Here's the code in a snippet (hopefully):



The moon empowers my blade and commands me to destroy you all!
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 20th Apr 2003 05:08 Edited at: 20th Apr 2003 05:09
First off, try something as simple as renaming your variable. Instead of using forward, use something stupid like apieceofcheese. If that doesn't work, try swapping lines 19 and 20. Do you still get the error on line 19? That would mean there's something wierd about line 19. The way to fix that would be to just leave line 19 blank. If that's not the problem, go through your program and where you use the forward variable, just put the value of forward (which seems to be one). Look for ways around the wall. Just a few suggestions.

solo
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 20th Apr 2003 12:46
you forgot to declare the True and False types:

global True AS INTEGER = 1
global False AS INTEGER = 0

just add 'as integer' to these, and the error message is gone.

[solo]

Shining Moonblade
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 20th Apr 2003 17:07
Ah...many thanx Solo. I didn't think anything so stupid could cause problems like that. LOL.

@HZence

apieceofcheese LOL. I love it!

The moon empowers my blade and commands me to destroy you all!

Login to post a reply

Server time is: 2026-07-11 04:22:55
Your offset time is: 2026-07-11 04:22:55