Gamers VM Examples

Started by
-1 comments, last by gamersvm 12 years, 8 months ago
This are codes and image examples of Gamers VM programming. All this examples are also in the installation file. Go below for the images.


3D example:

Var{

Fint : x,y,x1,y1,z,nxt=0,handle,handle1,handle2,ide,eq,indx=3,sp,ident=1,bool;

String : buf,fname,cm,chr;

}

file{
crate1.g3d;
crate2.g3d;
}

window

{

oncreate{

/Left-Top/

x=605;

y=500;

setwindowheight(y);
setwindowwidth(x);

x=505;
y=100;

createlabel(ident,x,y);

buf="Press,
1 and 2 - Select obj;
q and w - Rotate;
e and r - Rotate obj;
s and d - Scale;
z and x - Move;
h and j - hide/show;
Click to set Rotate.
Click to stop Rotate.";

setlabeltext(ident,buf);

setwinatdc();

x=0;
y=0;

/Right-Bottom/

x1=500;

y1=windowheight();

openglarea(x,y,x1,y1);

fname="crate1.g3d";

handle1=loadg3dfile(fname);

fname="crate2.g3d";

handle2=loadg3dfile(fname);

handle=handle1;
getmovev(handle,x,y,z);

}

onclick{
nxt=nxt+1;

if (nxt=1){
sp=20;
y=1;
x=0;
z=0;
setrotate(handle,x,y,z,sp);
}

if (nxt!=1){
nxt=0;
sp=0;
y=0;
x=0;
z=0;
setrotate(handle,x,y,z,sp);
}

}

onkeypress{
chr=getkeypress();
eq=1;

cm="1";
eq=comparetext(chr,cm);

if (eq=0){
handle=handle1;
}

cm="2";
eq=comparetext(chr,cm);

if (eq=0){
handle=handle2;
}


/if q rotate everything on the opengl area to right/
cm="w";
eq=comparetext(chr,cm);

if (eq=0){
z=0;
x=0;
y=y-2;
rotatecam(x,y,z);
}

/if q rotate everything on the opengl area to left/
cm="q";
eq=comparetext(chr,cm);

if (eq=0){
z=0;
x=0;
y=y+2;
rotatecam(x,y,z);
}

/if e rotate all the objects in the handle/
cm="e";
eq=comparetext(chr,cm);

if (eq=0){
getrotatev(handle,x,y,z);
y=y-20;
rotate(handle,x,y,z);
}

/if r rotate all the objects in the handle/
cm="r";
eq=comparetext(chr,cm);

if (eq=0){
getrotatev(handle,x,y,z);
y=y+20;
rotate(handle,x,y,z);
}

/scale all the object in the handle (decrease the size of the objects)/
cm="s";
eq=comparetext(chr,cm);

if (eq=0){
getscalev(handle,x,y,z);
x=x-0.01;
y=y-0.01;
scale(handle,x,y,z);
}

/scale all the object in the handle (increase the size of the objects)/
cm="d";
eq=comparetext(chr,cm);

if (eq=0){
getscalev(handle,x,y,z);
x=x+0.01;
y=y+0.01;
scale(handle,x,y,z);
}


/move to left/
cm="z";
eq=comparetext(chr,cm);

if (eq=0){
getmovev(handle,x,y,z);
x=x-0.1;
move(handle,x,y,z);
}

/move to right/
cm="x";
eq=comparetext(chr,cm);

if (eq=0){
getmovev(handle,x,y,z);
x=x+0.1;
move(handle,x,y,z);
}

/hide an entire object/
cm="h";
eq=comparetext(chr,cm);

if (eq=0){
bool=1;
hide(handle,bool);
}

/show the object/
cm="j";
eq=comparetext(chr,cm);

if (eq=0){
bool=0;
hide(handle,bool);
}

}
}

Animation Examples:
They are three ways of animating images in gamers VM programming.

Example 1:

var{
image:steps,stepp,stepps,step1=%s1.png%;
fint:x,y,sec,width,ident,aid=1,arr;
string:buf,lnm;
}


file{
list.txt;
list1.txt;
list2.txt;
}

image{
s1.png;
s2.png;
s3.png;
ss1.png;
ss2.png;
ss3.png;
}


window{
oncreate{
x=20;
y=20;
ident=1;
createlabel(ident,x,y);
buf="press any key to stop one and release the key to start the animation again.";
setlabeltext(ident,buf);

width=500;
setwindowwidth(width);

x=20;
y=50;

/draw the first image/
steps=step1;
drawimg(x,y,steps);

x=300;
y=50;

/draw the second image/
stepp=step1;
drawimg(x,y,stepp);

x=200;
y=50;

/draw the third image/
stepps=step1;
drawimg(x,y,stepps);


x=20;
y=50;

x=x+1;

/set delay seconds to 80/
sec=40;

arr=3;
lnm="list.txt";
aid=1;
animatelist(aid,steps,lnm,sec,arr);

arr=3;
lnm="list1.txt";
aid=2;
animatelist(aid,stepp,lnm,sec,arr);

arr=6;
lnm="list2.txt";
aid=5;
animatelist(aid,stepps,lnm,sec,arr);


}

onkeyup{
arr=3;
lnm="list1.txt";
aid=2;
animatelist(aid,stepp,lnm,sec,arr);
}

onkeydown{

/stop the animation with ident=2/
aid=2;
stoplistanim(aid);

}
}


Example 2:

Var{
Fint : sec=50 ,ident=1;
Image : imgvar;
String : giffile;
}

image{
logo.gif;
}

window
{
oncreate{
giffile="logo.gif";
animategif(ident,imgvar,giffile,sec);
}

onclick{
stopgifanim(ident);
}

onkeypress{
animategif(ident,imgvar,giffile,sec);
}
}


Example 3:

var{
image:steps,stepp,stepps,step1=%s1.png%,step2=%s2.png%,step3=%s3.png%,stepb1=%ss1.png%,stepb2=%ss2.png%,stepb3=%ss3.png%;
fint:x,y,sec,width,nxt,ident,aid=1,tee=1,arr,nxt2,te=2,tt=3;
string:buf;
}

image{
s1.png;
s2.png;
s3.png;
ss1.png;
ss2.png;
ss3.png;
}


window{
oncreate{
x=20;
y=20;
ident=1;
createlabel(ident,x,y);
buf="press any key to stop one";
setlabeltext(ident,buf);

width=500;
setwindowwidth(width);

x=20;
y=50;

/draw the first image/
steps=step1;
drawimg(x,y,steps);

x=300;
y=50;

/draw the second image/
stepp=step1;
drawimg(x,y,stepp);

x=200;
y=50;

/draw the third image/
stepps=step1;
drawimg(x,y,stepps);


x=20;
y=50;

x=x+1;

/set delay seconds to 80/
sec=80;
nxt=0;

/create the array/
arr=3;
setimgarraylen(tee,arr);

/load the images/
nxt2=1;
copyimgtoind(tee,nxt2,step1);
nxt2=2;
copyimgtoind(tee,nxt2,step2);
nxt2=3;
copyimgtoind(tee,nxt2,step3);

/call animate to animate the images/
aid=1;
animate(aid,steps,tee,sec,arr);


arr=3;
setimgarraylen(te,arr);

nxt2=1;
copyimgtoind(te,nxt2,step1);
nxt2=2;
copyimgtoind(te,nxt2,step2);
nxt2=3;
copyimgtoind(te,nxt2,step3);

aid=2;
animate(aid,stepp,te,sec,arr);



arr=3;
setimgarraylen(tt,arr);

nxt2=1;
copyimgtoind(tt,nxt2,stepb1);
nxt2=2;
copyimgtoind(tt,nxt2,stepb2);
nxt2=3;
copyimgtoind(tt,nxt2,stepb3);

aid=6;
sec=20;
animate(aid,stepps,tt,sec,arr);
}


onkeydown{

/stop the animation with ident=2/
aid=2;
stopanim(aid);

}
}

Cursor Examples:

Costum Cursor:

var{
fint:x,y,none;
image:cur=%cur.png%;
}

image{
cur.png;
}

window{

oncreate{
none=-1;
setcursor(none);
}

onmousemove{
getmousepos(x,y);
drawimg(x,y,cur);
}

}

System Cursor:

Var{
fInt:cur;
}

window
{

oncreate{
/check constant.exe file for cursor numbers/
cur=-3;
setcursor(cur);
}

}

Playing music:

Var{
String : fname,buf;
fInt : loop,ident,x,y,size,color;
}

sound{
test.mp3;
}

window
{
oncreate{

ident=1;
x=100;
y=50;

createlabel(ident,x,y);

color=255;
setlabelfontcolor(ident,color);

size=20;
setlabelfontsize(ident,size);

buf="Playing";
setlabeltext(ident,buf);



/assign the filename to a string variable without adding directory path/
fname="test.mp3";

loop=-1;
/loop is now = -1 which is infinite/

playmusic(fname,loop);
}

onclick{
/pause the music/
pausemusic();

buf="Pause";
setlabeltext(ident,buf);
}

onkeypress{
/resume the music/
resumemusic();

buf="Playing";
setlabeltext(ident,buf);
}

onclose{
/stop the music before closing/
stopmusic();
}
}

Playing Sound:

Var{
String : fname,buf;
fInt : ident,ident1,loop,x,y,size,color;
}

sound{
ringin.wav;
}

window
{
oncreate{

ident1=1;
x=100;
y=50;

createlabel(ident1,x,y);

color=65408;
setlabelfontcolor(ident1,color);

size=20;
setlabelfontsize(ident1,size);

buf="Click To Play";
setlabeltext(ident1,buf);

}


onclick{
/assign the filename to a string variable without adding directory path/
fname="ringin.wav";

/loop=0 which means play once/
loop=0;

/given the file identification/
ident=1;

playsound(ident,fname,loop);
}
}

Textbox:
Var{
fInt : ident,x,y,width,height,wordw,scroll,size,color;
}

window
{
oncreate{
/the textbox identifier/
ident=1;

/x and y position/
x=50;
y=50;

width=200;
height=200;

/wordwrap and autoscroll set/
wordw=0;
scroll=1;

/create the textbox/
createtextbox(ident,x,y,width,height,wordw,scroll);

/changing default font size to 10/
size=10;
settbfontsize(ident,size);

/changing the default font color/
color=16711680;
settbfontcolor(ident,color);

}

onclose{
/delete textbox before the window close/

deletetextbox(ident);
}
}

This topic is closed to new replies.

Advertisement