My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MakingARockmeter  
Your Guide to FoFiX 4.x's New Rockmeter
Featured, Phase-Implementation
Updated Sep 28, 2011 by n_hyd...@comcast.net

Introduction

Custom rockmeters are something that have been in development since the beginning of FoFiX 4. They allow themers to take the in-game visuals even further than before by no longer being restricted to the Guitar Hero or Rockband style. This even helps us as programmers because we no longer have to be the ones to get the rockmeters looking as close to the originals as possible. Changing from hard-coded to flexible .ini files really helps code maintainability as well as allows the community to be way more creative with FoFiX than ever before. So let's take a look at how this is done. All examples given will come directly from MegaLight v4 which is packaged with all copies of FoFiX 4




The Layer

Let's start of with an already made layer from MegaLight v4

[layer0:Image]
texture = bar.png
yscale = 270
xscale = 100
inPixels = xscale|yscale
valignment = bottom
rect = (1.0/3.0, 2.0/3.0, 1.0-rock, 1.0)

This layer is actually very basic in terms of what you can do, which makes it a perfect example for explaining.

The Header

The header of the layer defines which layer number it is and what type it is.

  • numbers can range from 0-99
  • there are 4 types: Image, Text, Circle, and Custom, all of which I will explain later

[layer<Number>:<type>]

Common Parameters

These are parameters shared across all layer types

ParameterDescriptionEvaluatableThings to consider
x/yposposition on screenYesBottom Left = (0.0,0.0), Top Right = (1.0,1.0)
x/yscalehow much the layer will be scaled by.YesNegative values will flip the image
colorColor saturation of the layerNoThe values are Hex with either 3 or 4 channels. #000000 is black, #FFFFFF is full color
alignmentside by which the layer will be anchored (horizontal)Nopossible values are LEFT, RIGHT, and CENTER
valignmentside by which the layer will be anchored (vertical)Nopossible values are TOP, MIDDLE, and BOTTOM
inPixelsdetermines which values are in terms of pixelsNofor x/ypos screen is in scale of 800x600 resolution
conditionwhen should the layer renderYesand and or from python can be used in this. Remember python boolean standards when writing conditions

Layer Specific Parameters

Image Layer

ParameterDescriptionEvaluatableThings to consider
textureThe image file to use for the layerNoThe default directory for image files is the rockmeter folder within the theme
rectCropping rectangle for the imageYesorder of values is left, right, top, bottom. Values need to be between 0 (Left/Top edge) to 1.0 (Right/Bottom edge)

Font Layer

ParameterDescriptionEvaluatableThings to consider
textThe text to be drawnYesIf you want to add variables into a string follow the modulo substituion rules for strings.
fontThe font to be used by the layerNoFonts are in terms of their engine name for now. Hopefully this will be fixed in the future
replaceReplaces characters in the stringNoSplit by character on the left will be replace with the character on the right
useCommaWhen drawing numbers, use a comma every 3 digitsNoRockband does this and it is the traditional way to write large numbers
shadowText will cast a shadowNoTrue or False
outlineText will have a blurry outline around itNoThe outline is of the same color as the text
shadowOpacityThe alpha value of the shadowNo0.0 = No shadow, 1.0 = solid black

Circle Layer

ParameterDescriptionEvaluatableThings to consider
textureThe image file to use for the layerNoThe default directory for image files is the rockmeter folder within the theme
ratioPercentage of the circle to be drawnYes




The Effect

Effects are applied each time the layer is updated. Effects can be as simple as sliding the layer across the screen to animating explosions if you feel like it.

[layer18:fx0:Fade]
color = #FFFFFF00
fadeTo = #FFFFFFFF
transitionTime = 1000.0
condition = self.stage.scene.countdownOK

This layer fades in the timer once the countdown starts

The Header

The header of the layer defines which layer the effect belongs to, which effect it is, and what type it is.

  • effects numbers can range from 0-5
  • there are 5 types: Slide, Scale, Fade, Replace, Animate

[layer<Number>:fx<Number>:<type>]

  • Things to take notice of: the higher the number of the layer or group, the further front it will be when rendered! As for effects, the higher the number the greater its priority.

Incrementing Effects

These effects are special in that they will smoothly transition between start and end values in a specified amount of milliseconds. The effects that are capable of doing this are Slide, Scale, and Fade.

Common Parameters

ParameterDescriptionThings to consider
TransitionTimeTime in milliseconds it takes to transition to the end values
TransitionTimeOutTime in milliseconds it takes to transition back to the start values
conditionDetermines when the effect is transitioning to end (True) or start (false)

Slide/Scale Parameters

ParameterDescriptionThings to consider
startX/YStarting x/y position or width/heightwork the same way as with the original group or layer's properties
endX/YEnding x/y position or width/height

Fade Parameters

colorStarting colorcan be 3-4 channel Hexadecimal color (think HTML)
fadeToEnding color

Other Effects

These effects are very closely related in how they are programmed, but their function is a bit different.

Replace

Replace will replace the layer's contents with that specified by the effect

ParameterDescriptionThings to considerApplies to
texturetexture to replace the image withYou can have multiple images and conditions by splitting them with the '|' characterImageLayers and everything extending them
rectnew rect for the imagesame as abovesame as above
textnew words to rendersame as aboveFontLayer

Animate

Animate only works with ImageLayers and will automatically parse the image's rect horizontally for it to scroll through.

ParameterDescriptionThings to consider
framesAmount of frames in the animationIt already works in relation to the parent's rect, so you can even have multiple animations in one image if you feel the need
fpsRate at while the image scrolls through the framesEven if you're gettin 800+ fps, this restricts the animation to run at however many you set. This works in the opposite way as well, if you're getting 15 fps and you have the animation set to 30 fps, it will skip frames




The Group

Groups are designed to be like layer groups in applications like photoshop. Groups are a subclass of layers themselves, so certain effects can be applied to them (Slide, Scale, and Fade) and can have all the common parameters applied to them as well.

[Group1]
layers = 8,9,10,11

[Group1:fx0:Slide]
startX = 1.3
endX = 1.0
startY = .145
endY = .145
transitionTime = 1000.0
condition = self.stage.layerGroups[2].position[1] >= .05

The Header

The header of the group defines which group number it is.

  • numbers can range from 0-50

[Group<Number>]

  • Remember: All parameters, headers, etc. are CaSe SEnSiTivE!

Group Specific Parameters

ParameterDescriptionThings to consider
layerslist of the layers that you want included (just their numbers), divided by commaswhile it is not necessary, it is considered go practice to declare your groups after the layers that are required in the group are typed up in your rockmeter.ini




List of Available Variables

Variable nameStored ValueThings to Consider
playerobject that represents the player
playerNumthe player number
playerNamethe player's name
partthe player's part/instrument
scoreplayer's scorereplaced with CoOp score in CoOp modes
streakplayer's streak
streakMaxamount of notes it takes to hit max multiplier40 is normal, 60 for bass guitar
powerstar power fill amountvalue between 0.0 and 1.0
starshow many stars earnedMaximum is 6-7 stars
partialStarspercentage of the current star earnedvalue between 0.0 and 1.0
rockrock meter fill amountvalue between 0.0 and 1.0
coop_rockcoop rock meter fill amountonly available in CoOp modes
multiplierplayer's multiplier
bassgrooveif a player is a bass guitar and their streak is over 30, they enter bass groove
boostkeeps track if a player is boosting their multiplier (star power/overdrive activated)
minuteshow many minutes into the song it is
secondshow many seconds into the song it is (0-59)
minutesCountdownhow many minutes left
secondsCountdownhow many seconds left
songLengthlength of the song (milliseconds)
minutesSongLengthlength of the song in minutes
secondsSongLengthlength of the song in seconds (0-59)
positionmillisecond position in the song
countdownPositionmilliseconds left
progressthis gives a percentage of how far the song has playedbetween 0.0 and 1.0




Advanced Variable Manipulation (ADVANCED TOPIC)

Not satisfied with the variables provided? You can go even further when referencing variables if you know enough of the code base. Use self.stage to get access to the rockmeter class's variables and self.stage.scene to get access to the GuitarScene class. Example of a possibly important one for you?

self.stage.scene.boardY

That variable is the tracker for the time into the animation for the fretboard transitioning in before the song starts. Another example is given earlier in the examples for effects and groups. Hope this cleared things up for you if you saw those values and had no idea what they were. Congrats, you just learned a bit of python.




About Custom Layers (ADVANCED TOPIC)

Custom Layers are for when you want to do something that the code that is already available to themers isn't capable of doing. You need to know python if you want to do this, and you need to be familiar with the code of the Rockmeter.py. If you are not careful you can break your game. This is fully executable code read in by the engine.

To start creating a custom layer you first need to make a file in your theme's folder called CustomRMLayers.py. To have access to all the rockmeter's code and global variables you need to add this to the top of the file.

from Rockmeter import *

From there on just start working your programming magic. We're not here to teach you python, but if you already know it you can take advantage of your knowledge and freely use it in your rockmeter. Remember, because Groups extend the base Layer class for rockmeters, you can even have custom groups!

Powered by Google Project Hosting