Is there an Onkeyrelease comand in Dark GDK

is there any on key release commmand in Dark dgk.

I'm trying to get my character to play the facing left animations after the play has pressed the moving left key. So far the method I've been using isn't working perfectly but its working.

Any way the problem is that my character accesses the FACING LEFT ANIMATION in the middle of playing the MOVING LEFT ANIMATIONS

code here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "darkGDK.h"

void DarkGDK (void)
{
	dbSyncOn();
	dbSyncRate(60);
	dbDisableEscapeKey();

	dbSetImageColorKey(255,0,255);/*this sets transparency of the colour stated in digits(R,G,B)
								  in the case above, the transparent colour is PINK,
								  it has the value [(R)255,(G)0,(B)255]
								  */
	
	dbLoadImage("wall.bmp",2);

	dbSprite(2,400,50,2);

	dbCreateAnimatedSprite(1,"playerwalkcycle.bmp",14,2,1);
	/* /1/**the First number, 14, represents the number of frames 
	that the user has horizontally on the IMAGE WITH THE ANIMATION
	FRAMES SEQUENCE**
	**/2/**the Second number,1, represents the number of frames
	that the user has vertically on the IMAGE WITH THE ANIMATION
	FRAMES SEQUENCE
	3THE THIRD NUMBER IS THE IMAGE ID:*/;

	dbSprite(1,100,50,1);/*the number 1 is the Sprite load IDentity, 
						 the number 100 is the X coordinate(Horizontal,flat),
						 and the number 50 is the Y coordinate(Vertical, UP)
						 the number at the end is the original image number*/
 

	//dbOffsetSprite(1,dbSpriteWidth(1) / 2,dbSpriteHeight(1) / 2);

	//dbOffset declares the centre of your sprite, & db height/width guesses the height/width 

	/*dbRotateSprite(1,90);/* the NO. 1 is the Sprite load IDentity,
						 and the NO. 90 represents the (90degrees)degrees at 
						 which the (ID: 1)sprite will be rotated
						 */
	bool bFaceRight;


	while (LoopGDK())
	{
		//dbRotateSprite(1,dbSpriteAngle(1) + 1);



		//THIS IS FOR MOVING RIGHT
		if(dbRightKey() == 1)
		{
			
		dbPlaySprite(1,6,12,90);
			
		dbRotateSprite(1,90);
		dbMoveSprite(1,1);/* the NO. 1 is the Sprite load IDentity,
						  and the other number 1 is the velocity(speed) at which the
						  Sprite moves at.
						  Another note: Sprites always move natively at 0degrees
						  (it means it will always go up)
						  */
		dbRotateSprite(1,0);
		
		bFaceRight = true;
				
		/*dbPlaySprite(1,6,12,100);
		the first number(1)represents the sprite id
		 the second number(6)represents the frame which we start to loop from
		 the third number(12)represents the last frame we end the loop
		 the last number (100)represents the speed of the animation*/
		
		if(dbSpriteCollision(1,2) == 1)
		{/*the NO.270degrees tells the sprite to go face left
		 dbMove tells it to move facing the left direction.
			(& then final rotate returns object to normal after the turn),telling 
				sprite to go opposite direction*/
		dbRotateSprite(1,270);
		dbMoveSprite(1,1);		
		dbRotateSprite(1,0);
		}
		
		}
		//THIS IS FOR MOVING LEFT,
		if(dbLeftKey() == 1)
		{
			
		dbPlaySprite(1,20,26,90);
			
		dbRotateSprite(1,270);
		dbMoveSprite(1,1);/* the NO. 1 is the Sprite load IDentity,
						  and the other number 1 is the velocity(speed) at which the
						  Sprite moves at.
						  Another note: Sprites always move natively at 0degrees
						  (it means it will always go up)
						  */
		
		dbRotateSprite(1,0);
		//onkeyrelease
		bFaceRight = false;

		if(dbSpriteCollision(1,2) == 1)
		{//I'm telling the object to go opposite direction on collision
		dbRotateSprite(1,90);
		dbMoveSprite(1,1);		
		dbRotateSprite(1,0);
		}
		}


		//THIS IS FOR MOVING DOWN,
		if(dbDownKey() == 1)
		{
		dbRotateSprite(1,180);
		dbMoveSprite(1,1);		
		dbRotateSprite(1,0);
		if (dbSpriteCollision(1,2) == 1)
		{//I'm telling the object to go opposite direction on collision
		dbRotateSprite(1,0);
		dbMoveSprite(1,1);		
		dbRotateSprite(1,0);
		}
		}


		//THIS IS FOR MOVING UP
		if(dbUpKey() == 1)
		{
		dbRotateSprite(1,0);
		dbMoveSprite(1,1);		
		dbRotateSprite(1,0);
		if (dbSpriteCollision(1,2) == 1)
		{//I'm telling the object to go opposite direction on collision
		dbRotateSprite(1,180);
		dbMoveSprite(1,1);		
		dbRotateSprite(1,0);
		}
		}

		if (bFaceRight == true)
		{
		dbPlaySprite(1,1,5,100);
		}

		if (bFaceRight == false)
		{
			dbPlaySprite(1,15,19,100);
		}

		if(dbEscapeKey() == 1)
		{
			break;
		}
		dbSync();
	}
	
	for( int i = 1; i < 10; i ++)
	{
	dbDeleteImage(i);

	dbDeleteSprite(i);
	}


	return;
}

Last edited on
Sorry that some of the notes are a bit messed up
Topic archived. No new replies allowed.