Gw Temp
Menu
Tutorial - 'C++ Scrolling background' by Xfactor
An item about Programming Languages posted on
Blurb
How to create a scrolling background in C++
Body
Edit by Hiretsukan: This is not a real C++ tutorial, so anyone who wants to learn anything whatsoever about C++ had best go elsewhere. Sorry.
Have you ever wondered how the programmers, made the screen slides with your character in C++. Then wonder no more, these codes below are the key to create your game scrooling background.
In this tutorial, when you see"//", they are comments in order to eplain what the line of codes does.
if it's not clear enough email me at: jeromefabio@hotmail.com.
I am just trying to help out the newbies out there, especially those who are going to be game programmers, i would suggest, you tackle C++ as soon as possible, trust me.
// Project : slide
// Copyright (c) 2003 by Xfactor
//
// Slider example
// Create Static Display control
myStatic=New StaticText(CurWindow,"",10,10,200,20,StaticText.NOBORDER);
myStatic.SetBackColor(GetRGB(192,192,192));
myStatic2=New StaticText(CurWindow,"",10,30,200,20,StaticText.NOBORDER);
myStatic2.SetBackColor(GetRGB(192,192,192));
// Create Slider
mySlider=New Slider(CurWindow,10,60,220,30,Slider.AUTOTICKS,Slider.HORZ,Slider.TOOLTIPS,Slider.ENABLESELRANGE,Slider.NOBORDER);
mySlider.SetTickFrequency(10);
mySlider.OnScroll=SliderPosChanged;
mySlider.SetRange(0,100);
// Wait for user Input
While(1);
//---------------------
// Function CallBack
//---------------------
Function SliderPosChanged(sliderObj, pos)
{
myStatic.SetText("New Position : "+pos);
myStatic2.SetText("Selection : From "+mySlider.GetSelectionStart()+" To "+mySlider.GetSelectionEnd());
}
Do you see how very simple it is.