Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TedMar), 1,031 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Problem with Changing Sprite of a 2D Actor #188614
03/15/08 17:06
03/15/08 17:06
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. this is a great edit of my mini Script ^^
i edited it, so i only have 1 Function, but different handles to call the directions and sprites.

here´s the code:
Code:

//////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
//////////////////////////////////////////////////////////////////////////
//
// VARIABLEN DEFINIEREN
//
//////////////////////////////////////////////////////////////////////////

var sprite_frames = 6; // Spriteanzahl fur Standani
var switcher = 0; // Sheetswitcher
var heldenblickrichtung = 6; // Der Name sagts schon

var counter = 0; // Startframe
var bewegungsmuster = 0; // Wie bewegt sich der Held


var tester = 0; // Nur für Debug Zwecke

BMAP* alucard_sheet = "Alucard_stand_r.tga";
STRING* debugger1 = bewegungsmuster;

//////////////////////////////////////////////////////////////////////////
//
// DIE WINDOWS
//
//////////////////////////////////////////////////////////////////////////

PANEL* hero =
{
window (320,240,24,48,alucard_sheet,counter,0);
flags = VISIBLE;
}

PANEL* shower =
{
window (0,500,800,64,alucard_sheet,0,0);
digits ( 10,10,10,*,1,counter);
digits ( 10,25,10,*,1,hero.size_x);
digits ( 60,25,10,*,1,sprite_frames);
digits ( 110,25,10,*,1,tester);
flags = VISIBLE;
}

//////////////////////////////////////////////////////////////////////////
//
// DIE BEWEGUNGSCODES
//
//////////////////////////////////////////////////////////////////////////


function move(bewegungsmuster)
{



if (bewegungsmuster == 6)
{
if (heldenblickrichtung != 6)
{
alucard_sheet = "Alucard_walk_r.tga";
hero.size_x = 40;
sprite_frames = 16;
counter = 0;
switcher = 0;
heldenblickrichtung = 6;
}
hero.pos_x += 3;
}

if (bewegungsmuster == 4)
{
if (heldenblickrichtung != 4)
{
alucard_sheet = "Alucard_walk_l.tga";
hero.size_x = 40;
sprite_frames = 16;
counter = 0;
switcher = 0;
heldenblickrichtung = 4;
}
hero.pos_x -= 3;
}

if (bewegungsmuster == 0)
{
if (heldenblickrichtung == 4 && switcher != 1)
{
alucard_sheet = "Alucard_stand_l.tga";
hero.size_x = 24;
sprite_frames = 6;
counter = 0;
switcher = 1;
}
if (heldenblickrichtung == 6 && switcher != 1)
{
alucard_sheet = "Alucard_stand_r.tga";
hero.size_x = 24;
sprite_frames = 6;
counter = 0;
switcher = 1;
}
}



}



//////////////////////////////////////////////////////////////////////////
//
// DIE SPRITE und KEY FUNKTION
//
//////////////////////////////////////////////////////////////////////////
function move_hero()
{
while(1)
{
if (key_d == 1) {move(6);}
if (key_a == 1) {move(4);}
if (key_a == 0 && key_d == 0) {move(0);}


tester = hero.size_x * sprite_frames;
wait(1);
}
}

function move_sprite()
{
while(1)
{
if (counter >= ((hero.size_x * sprite_frames) - hero.size_x))
{
counter = 0;
}
else
{
counter += hero.size_x;
}
wait(10);
}
}


//////////////////////////////////////////////////////////////////////////
//
// DIE MAIN FUNKTION
//
//////////////////////////////////////////////////////////////////////////

function main()
{
fps_max = 200;
video_mode = 7;
screen_color.blue = 150;
wait(-1);
move_hero();
move_sprite();
}



My problem is..
When i start the script, the actor moves by itself to a direction.. but i hit no key...
What should he do?
1.) He must play the stand animation when no key is hitten
2.) he must play the walking animations when a direction key is pressed
3.) The size of the Window must be variable, because the stand sprite has a Framesize of 24 pixels... and the walk animations of 40 pixels...

In this Zip File are the Prite_Lines i used in that code:

Hope someone knows an answer to this... <a href="/Sonstiges/players_movement.zip" target="_blank">>>Click me<<</a>
IMPORTANT!!!: The Script in that Zip Acrhive is an older version.. so don´t loom at them ^^.. just at the Sprites if you want to try some thing with them.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Error with a function call [Re: Espér] #188615
03/15/08 17:16
03/15/08 17:16
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
move_right; == false
move_right(); == ok

Re: Error with a function call [Re: Espér] #188616
03/15/08 17:18
03/15/08 17:18
Joined: May 2007
Posts: 175
Germany
dblade Offline
Member
dblade  Offline
Member

Joined: May 2007
Posts: 175
Germany
I think you forgot the parameters, when you call the functions, it should look like this:

Code:

move_right();
move_left();
move_stand();



Re: Error with a function call [Re: Espér] #188617
03/15/08 17:20
03/15/08 17:20
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
Yeah, move_right; is wrong.
It needs to be:
move_right();

Re: Error with a function call [Re: xbox] #188618
03/15/08 17:26
03/15/08 17:26
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline
Senior Member
Vadim647  Offline
Senior Member
V

Joined: Feb 2008
Posts: 337
Problems:
1. my_function(); not my_function;
2. Maybe use {} brackets...
3. Move_left() moved character right.
So, entire corrected code:
Code:

//////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
//////////////////////////////////////////////////////////////////////////

var sprite_stand_frames = 6; // Spriteanzahl fur Standani

var counter = 0; // Startframe

//////////////////////////////////////////////////////////////////////////

PANEL* hero =
{
//bmap = "Alucard_stand.tga";
window (320,240,24,48,"Alucard_stand.tga",counter,0);
flags = VISIBLE;
}

PANEL* wertausgabe =
{
digits ( 10,10,10,*,1,counter);
flags = VISIBLE;
}

//////////////////////////////////////////////////////////////////////////

function move_right()
{
hero.pos_x += 2;
wait(1);
}

function move_left()
{
hero.pos_x -= 2;
wait(1);
}

function move_stand()
{
while(1)
{
if (counter >= (24 * sprite_stand_frames))
{
counter = 0;
}
else
{
counter += 24;
}

wait(60);
}
}

//////////////////////////////////////////////////////////////////////////

function main()
{
fps_max = 60;
video_mode = 7;
screen_color.blue = 150;
wait(-1);

while(1)
{
if (key_d == 1) {move_right();}
if (key_a == 1) {move_left();}
if (key_a == 0 && key_d == 0) {move_stand();}
wait(1);
}
}




I switched to other account since marth 2010. Guess which.
Re: Error with a function call [Re: Vadim647] #188619
03/15/08 17:37
03/15/08 17:37
Joined: May 2007
Posts: 175
Germany
dblade Offline
Member
dblade  Offline
Member

Joined: May 2007
Posts: 175
Germany
Code:

while(1)
{
if (key_d == 1) {move_right();}
if (key_a == 1) {move_left();}
if (key_a == 0 && key_d == 0) {move_stand();}
wait(1);
}



I think this is a possible way but in LiteC it's not necessary that you use brackets when you only call one function so this is also alowed:

Code:

while(1)
{
if (key_d == 1)
move_right();
if (key_a == 1)
move_left();
if (key_a == 0 && key_d == 0)
move_stand();
wait(1);
}



Re: Error with a function call [Re: dblade] #188620
03/15/08 17:46
03/15/08 17:46
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline
Senior Member
Vadim647  Offline
Senior Member
V

Joined: Feb 2008
Posts: 337
'{}' In that i'm wrong.
+1 I'm not sure, but move_stand() causes unit animation speed-up. If it's not planned, delete 'while (1) {' and 'wait(60)'. It will cause 1 pic frame per frame animation.
+2 If you want 1 frame\sec move 'move_stand' before 'while' loop in main.


I switched to other account since marth 2010. Guess which.
Re: Error with a function call [Re: Vadim647] #188621
03/15/08 17:54
03/15/08 17:54
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. if i use the code from Vadim647, the stand animation works to fast...
how to correct that?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Error with a function call [Re: Espér] #188622
03/15/08 18:31
03/15/08 18:31
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
You could chose a higher value at wait(60);


RE: Problem with showing a 2D Actor correctly [Re: Lukas] #188623
03/16/08 11:44
03/16/08 11:44
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Quote:

!!!!! Look at the Start Post !!!!!





Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1