Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 900 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: RE: Problem with showing a 2D Actor correctly [Re: Espér] #188624
03/16/08 12:25
03/16/08 12:25
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Extrem schwierig, den Code zu lesen, wenn die Klammern nicht richtig eingeschoben sind. So wie ich es verstehe, wird in der main while(1) Schleife
geschaut, ob key_a und key_d = 0 (NICHT GEDRüCKT) sind, worauf move(0)ausgeführt wird.
In der Function move wird der code ab "if (heldenblickrichtung == 6)" ausgeführt, und da steht "hero.pos_x -= 2;", womit der Player bewegt wird.
Warum hast du in der Function move() nochmals while(1) Schleifen? Ein mal eine Taste gedrückt und dein Hero bewegt sich immer weiter, auch wenn die Taste losgelassen wird.
Hoffe das hilft, Gruss aus der verschneiten Schweiz...

Re: Problem with showing a 2D Actor correctly [Re: Widi] #188625
03/16/08 14:19
03/16/08 14:19
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
Ich hab das Script im Startpost ma umeditiert.. jetzt bewegt sichd er Chara schneller... aber die Sprite wechselt er trotzdem nicht...

nunja.. die while(1) in den einzelnen Bewegungen, ist für die Animation des Sprite-Line-Sheets...

Der Player hat in dem Script 3 bewegungen.. weshalb im move(XXX) ja auch Statt dem XXX eine zahl steht..
Diese zahl steht für die Richtungen auf dem Ziffernblock der Tastatur.. also auch der Bewegungsrichtung ( 0 = stehen ).
Ich frage in der Function ab, ob bewegungsmuster ( der wert aus den Klammern ) == 4,6 oder 0 ist.. Je nachdem wird ein andrer Code ausgeführt..


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Changing Sprite of a 2D Actor [Re: Espér] #188626
03/19/08 18:07
03/19/08 18:07
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
I can´t edit the first post.... WHY????

So i must do it here.. i reedited the code, so i´ve two Scripts..
here´s the Main Code:
Code:

//////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include "players_movement.c"
//////////////////////////////////////////////////////////////////////////
//
// DIE MAIN FUNKTION
//
//////////////////////////////////////////////////////////////////////////

function main()
{
fps_max = 60;
video_mode = 7;
screen_color.blue = 150;
wait(-1);
move_hero(); // Starting Key If´s and movement
move_sprite(); // Starting Sprite animation
}




AND HERE, the Code for Player Movement:
Code:

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

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

var counter = 0; // Startframe
var bewegungstempo = 1; // Wie schnell bewegt sich der Held


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


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

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

PANEL* shower =
{
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,bewegungstempo);
flags = VISIBLE;
}

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


function move_hero()
{
while(1)
{
if (key_d == 1)
{
if (heldenblickrichtung != 6)
{
hero = bmap_create("Alucard_walk_r.tga");
hero.size_x = 40;
sprite_frames = 16;
counter = 0;
switcher = 0;
heldenblickrichtung = 6;
}
// hero.pos_x += bewegungstempo;
camera.x += bewegungstempo;
}

if (key_a == 1)
{
if (heldenblickrichtung != 4)
{
hero = bmap_create("Alucard_walk_l.tga");
hero.size_x = 40;
sprite_frames = 16;
counter = 0;
switcher = 0;
heldenblickrichtung = 4;
}
// hero.pos_x -= bewegungstempo;
camera.x -= bewegungstempo;
}

if (key_d == 0 && key_a == 0)
{
if (heldenblickrichtung == 4 && switcher == 0)
{
hero = bmap_create("Alucard_stand_l.tga");
hero.size_x = 24;
sprite_frames = 6;
counter = 0;
switcher = 1;
}
if (heldenblickrichtung == 6 && switcher == 0)
{
hero = bmap_create("Alucard_stand_r.tga");
hero.size_x = 24;
sprite_frames = 6;
counter = 0;
switcher = 1;
}
}
wait(1);
}
}



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




Same problem.. He doesn´t change the Sprite.... HELP


Ps.: with
Code:
hero.bmap = "Filename"


The Acknet.exe crashes... The game shuts down via Windows Error...

Last edited by xXReapeRXx; 03/19/08 19:22.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Changing Sprite of a 2D Actor [Re: Espér] #188627
03/19/08 18:55
03/19/08 18:55
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Code:

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


A panel definition inside a while loop that runs forever and is not included in a function?? Hell, how did you get the compiler to take that. That's total nonsense.
Code:
BMAP* alucard_sheet = "Alucard_stand_r.tga";


You're assigning an array of characters to a bitmap. You can't do that. If you want to set a bitmap you have to assign a bitmap, e.g. with bmap_create(). You have done this several times in you code. Always the same error.


Always learn from history, to be sure you make the same mistakes again...
Re: Problem with Changing Sprite of a 2D Actor [Re: Uhrwerk] #188628
03/19/08 19:12
03/19/08 19:12
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... the while(1) loop is deleted.. but how to use the bmap_create() code???

Can you give me an example, please?


Have updated the code above...

Last edited by xXReapeRXx; 03/19/08 19:22.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Changing Sprite of a 2D Actor [Re: Espér] #188629
03/19/08 20:08
03/19/08 20:08
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Once again you confused the types of your variables. You assigned a bitmap pointer to a panel pointer. An valid example would be
Code:
hero->bmap = bmp_create("Alucard_stand_r.tga");


If you do this continuously you will create a memory leak as you continue to create new bitmaps. A better solution would be loading bitmaps at the beginning of your code and assigning them later. E.g.:
Code:
BMAP* alu_stand_r;
BMAP* alu_stand_l;
...
void move_hero()
{
alu_stand_r = bmap_create("Whatever filename");
alu_stand_l = bmap_create( // and so on.
// Now imagine here all your loops and if statements and there:
hero->bmap = alu_stand_r;
}


If you're assigning variables in your code then always ensure they have the same type. If the type is different your code won't get compiled or you'll gain unwanted results including crashes.

Be sure to understand the concept of variables and types. Read the manual und lite-c -> variables.


Always learn from history, to be sure you make the same mistakes again...
Re: Problem with Changing Sprite of a 2D Actor [Re: Uhrwerk] #188630
03/19/08 20:14
03/19/08 20:14
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..but i can´t just load Bitmaps.. i must animnate them.. so they are Sprite-Lines...
I must create a panel with a window ( see the code ).. and the bitmap of that window must be Changed.. BUT HOW...


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Changing Sprite of a 2D Actor [Re: Espér] #188631
03/19/08 20:56
03/19/08 20:56
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
If you want to use the window then place all animation frames in one bitmap and use varX and varY of the window to animate it.


Always learn from history, to be sure you make the same mistakes again...
Re: Problem with Changing Sprite of a 2D Actor [Re: Uhrwerk] #188632
03/19/08 21:03
03/19/08 21:03
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
Yes.. but.. my Problem is, if i create the Bitmaps like you said:
Code:

...
BMAP* alu_stand_r;
BMAP* alu_stand_l;
BMAP* alu_walk_r;
BMAP* alu_walk_l;


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

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

PANEL* shower =
{
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,bewegungstempo);
flags = VISIBLE;
}

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


function move_hero()
{
alu_stand_r = bmap_create("Alucard_stand_r.tga");
alu_stand_l = bmap_create("Alucard_stand_l.tga");
alu_walk_r = bmap_create("Alucard_walk_r.tga");
alu_walk_l = bmap_create("Alucard_walk_l.tga");

while(1)
{
...



The Bitmaps are shown in the upper left corner.. here´s a screen:


i want the hero Sprite ( the centered one ) to be changed...


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Problem with Changing Sprite of a 2D Actor [Re: Espér] #188633
03/19/08 22:32
03/19/08 22:32
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
If you want to change an entities appearance you should either use the frame parameter and create a bitmap in the form "mybitmap+9.bmp" or use the ent_morph() instruction.


Always learn from history, to be sure you make the same mistakes again...
Page 2 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