Errors, where?
Blitz3D Forums/Blitz3D Beginners Area/Errors, where?
| ||
Well, I'm trying to create somekind of Algorithms for my character however as you can see below ini_Samus(StandL) it doesn't draw the right frame it draws the StandR frame not frame 22, see anything wrong? Full Code Below Graphics 640,480,16,2 ; GLOBAL VAR Global Draw_Samus = 1 Global quit = False Global Frames Global TheTimer Global AnimDelay ; IMAGES Global SamusSprites=LoadAnimImage("images\MR_Samus.png",56,56,0,55) MaskImage SamusSprites,255,255,255 ; SET BUFFER SetBuffer BackBuffer() Frames = 12 AnimDelay = 100 ;----------------------------------------- ; MAIN LOOP While Not KeyDown(1) Or quit = True ; Samus SYS If Draw_Samus = 1 Then ini_Samus(StandL) EndIf Flip:Cls Wend End ;----------------------------------------- ; TYPES Type Player Field Name$ Field HealthBanks% Field Healt% Field x%,y% Field jump% Field gravity% End Type Type Weapon Field Name$ Field MinDam% Field MaxDam% Field Info$ End Type ;----------------------------------------- ; FUNCTIONS Function ini_Samus(Dir$) ;----------------------- Select Dir$ Case StandR ; Stand Right Frames = 11 DrawImage SamusSprites,sX,sY,Frames Case StandL ; Stand Left Frames = 22 DrawImage SamusSprites,sX,sY,Frames Case RWalk ; Walking Right without Gun Point If Frames = 22 Then Frames = 12 DrawImage SamusSprites,sX,sY,Frames sX = sX + 1 If TheTimer+AnimDelay < MilliSecs() Then TheTimer = MilliSecs() Frames = Frames + 1 End If Case LWalk ; Walking Left without Gun Point Default Notify "Theres an error in the Player Routines." : End End Select ;---------------------- End Function |
| ||
whats wrong is that your using a string varible, but you arn't passing string statments, You have, ini_Samus(StandL) your own function requires a String (Dir$) well what you just passed was a varible, a empty varible to be exact, 0, anyways, if your function is going to be setup to take in a string, then you need to pass strings ;) ini_Samus("StandL") PLUS your case select also needs to be setup in strings, gotta use them " .. Quotes ;) Case "StandR" ; Stand Right Case "StandL" ; Stand Left |
| ||
StandR, StandL, RWalk, and LWalk are all 0! The easiest thing is to make some constants: Const StandR = 1 Const StandL = 2 Const RWalk = 3 Const LWalk = 4 Now you can pass them in just like you're doing (like "ini_Samus(StandL)"). <EDIT: Paradox beat me to it> <EDIT: I didn't even notice it was taking a string. Probably easier to make the function take an int % instead of a string $... and just use the consts. |
| ||
yes exactly what I was going to say also Soja :) just wanted to point out his problem first, rather then say a different way to do it. But Yes, I would use Consts, and Int varibles instead, much nicer then strings ;) |
| ||
less readable then string no? Plus its using var u cant use in the future :( Wasting Var no? |
| ||
no... if you plan on using varibles named the same as strings, then you in for trouble :P now that would be less readable if StandL then ini_Samus("StandL") not good.. and about.. wasting a Var?... don't you worry, there are plenty of Vars for you to play with ;P Oh and working with numbers is faster then working with strings. |