Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: spook1 on Tue 08/11/2005 21:10:48

Title: move rawdraw objects along with a character
Post by: spook1 on Tue 08/11/2005 21:10:48
I have a problem with rawdraw functions, and character movement.

I want to draw certain sprites at coordinates that are relevant to a characters position.


This works fine, exept for the fact that the rawdraw functions are called, only when the character stops moving.

So: lets say i have the hat of my main character defined as sprite 160. And the relative coordinates of the head of my character (where the hat must be placed) are hatcoord.x, and hatcoord.y

I Draw the hat as follows:

RawDrawImage(cCharacter.x + Hatcoord.x , cCharacter.y + hatcoord.y  , spriteslot);

The problem that occurs is that the hat is draw in the correct place, but ONLY after the character has stopped moving?
How can I make the hat (sprite) move along weith the charcater?
In other words, how can I rawdraw during mcharacter movement?

It probably has to do something with nonblocking, wait ?? I cannot figure it out.

P.S. I need to workthis way because I have over 30 "hats".

any suggestions?

Martijn
Title: Re: move rawdraw objects along with a character
Post by: Pumaman on Tue 08/11/2005 21:14:19
Where have you put the script? In repeatedly_execute?

If you need it to happen during a blocking walk, put it in repeatedly_execute_always instead.
Title: Re: move rawdraw objects along with a character
Post by: spook1 on Tue 08/11/2005 21:28:08
thnaks for the fast reply !

I have put it in the a function int he global script and it is called in the room script in the repeatedly_execute.

I cannot find a repeatedly alwya section. can i create it myself?
Title: Re: move rawdraw objects along with a character
Post by: Gilbert on Wed 09/11/2005 01:20:13
Yes.

function repeatedly_execute_always() {


}
Title: Re: move rawdraw objects along with a character
Post by: spook1 on Wed 09/11/2005 12:13:55
Thnaks, it works great but slow...


here is my code:

//#################################################################KOOPS FUNCTION SHOW_WIRING #####################################
function DrawComponents(){
Ã,  int i;
Ã,  RawRestoreScreen();
Ã,  i=0;
Ã,  while(i < MAXHOTSPOTS){
Ã,  Ã,  if (ownhotspot[i].active == 1){
Ã,  Ã,  Ã, if (ownhotspot[i].spriteslot != -1) { //check if a sprite must be drawn, if not, no sprite should be defined
Ã,  Ã,  Ã,  Ã, RawDrawImage(cBike.x + ownhotspot[i].x -ownhotspot[i].sprite_width, cBike.y + ownhotspot[i].y - ownhotspot[i].sprite_height,ownhotspot[i].spriteslot);
Ã,  Ã,  Ã, }
Ã,  Ã,  }
Ã,  i++;
Ã,  }
}


Thios code is placed in the repeatedly_execute_always loop.

Obviously it is too much and slows down the game too much.

I do need the 30 'objects' (actually it is only 10 but since I have 3 sets of views for different perspective (right_side view of the bike, backside_view of the bike and left-side view of the bike) it adds up to 30.

Can this be solved in another way? Or am I forced to simplify the puzzle? :-(

Suggestions?
Title: Re: move rawdraw objects along with a character
Post by: Gilbert on Wed 09/11/2005 12:16:42
How big (width, height) are the sprites?
Also, is your game runing in hi-res 32bit using alpha channeled sprites?
Title: Re: move rawdraw objects along with a character
Post by: spook1 on Wed 09/11/2005 16:02:10
sprites are about 50 pixels height and width (sometimes I have wites, long and narrow, sometimes lightbulbs: round)
Typical size is  1 to 2 times the size of the standard blue cup.

The game is 640*480 resolution, 16 bit color.

Alpha channel???


Title: Re: move rawdraw objects along with a character
Post by: strazer on Wed 09/11/2005 18:08:13
Just using RawRestoreScreen in rep_ex causes significant frame drop on any system (see this discussion (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=14119)). If that concerns you, you may have to take another approach to your problem.
Title: Re: move rawdraw objects along with a character
Post by: spook1 on Wed 09/11/2005 19:54:18
Yep, I read the thread.

So no other option than another approach...
Too bad, but I was afraid so.

One more option may be to use less objects but mirror them somehow. Would that be possible in any way?

the left-sideÃ,  and right-side view are symetric.

Another idea: could I use multiple characters? each wire is a character and the characters move along with the vehicle. Disappearing when clikced and reappearing when clicked again. Some transparency option maybe? Like turn the characters into 'ghosts" when the wires are removed (metaphorically spoken)


For those of you interested in the exact puzzle:

To be exact:
I have a puzzle with a caterpillar vehicle. The engine for left and right side can be connected to a battery.
When headlights are connected (flashlight plugin will be used here), voltage over theÃ,  engine parrallel to the headlight drops and the vehicle starts turning. (when right headlight is connected, right engine slows down, vehicle turns right. You have to shut of the light to turn back, but then you cannot see the whole anymore)
This way I want to follow a track in the dark. The player has to connect battery and headlights in a sensible way to finish the track.

Learning goal is to get used to the non-local effects of connecting an element in a circuit.
I hope the puzzle is challenging enough for the student to keep going and effective enough to remember the essential message hidden in it...

The caterpillar vehicle is drawn in three views: straight, left-side and right side.
Once you get of the road you loose, you have to avoid wholes in the road and you have to keep up to speed (connect two batteries in series)

Title: Re: move rawdraw objects along with a character
Post by: Ishmael on Wed 09/11/2005 20:18:05
Can't you use the Character.Follow command to make the hat follow the character? Look it up in the manual for the matter if you already haven't.
Title: Re: move rawdraw objects along with a character
Post by: spook1 on Wed 09/11/2005 20:21:42
great idea I guess. Our contributions just crossed, as I asked in my previous post about this ;-)

I can make character invisible, yet clickable by setting transparency to 100% I found out in http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22558.0

great!