Page 3 of 4
Re: actor n background

Posted:
Mon Jun 11, 2012 4:24 pm
by dzuncoi
anyone can help me ? i still cant fix it

Re: actor n background

Posted:
Mon Jun 11, 2012 5:01 pm
by skydereign
Please be patient (at least wait a day for people to respond between posts). gE cuts an image into n frames. For your image, it cuts it into 7 frames. The image is 397 pixels in width, so each frame is 56 pixels wide. If you want to see the first frame, just look at the first 56 pixels (in width). You'll notice that hercules is not centered in the frame. Same for most of the other frames.
To animate that properly, hercules needs to be in the center of each frame. I suggest taking a look at other animations. It should become fairly obvious why your animation is messing up, and how you should fix it.
Re: actor n background

Posted:
Tue Jun 12, 2012 7:50 am
by dzuncoi
thank u, i got it, now i can make it move better
Re: actor n background

Posted:
Wed Jun 13, 2012 4:42 pm
by dzuncoi
hello guys, can anyone show me how to create animation randomly ? such as i have 2 run-right animations n add them to key down event (both with "right" key) n i want it moves randomly with these animations.
Re: actor n background

Posted:
Wed Jun 13, 2012 4:47 pm
by skydereign
There is a function called rand, which returns a random number between 0 and the number you pass it. You can use this to make different things happen randomly.
- Code: Select all
int random = rand(2); // returns a number between 0 and 2 (including floating point)
// setting it to an int casts it (making random equal 0 or 1)
switch(random)
{
case 0:
// Change animation to first run
break;
case 1:
// Change animation to second run
break;
}
Re: actor n background

Posted:
Wed Jun 13, 2012 4:53 pm
by dzuncoi
oh, so simple

thank u, btw, where can i get these kinds of code ?
Re: actor n background

Posted:
Wed Jun 13, 2012 4:56 pm
by dzuncoi
ar, what if it returns to 2 ? because u make it equal to rand(2), so i think it gets 3 values: 0,1,2 right?
Re: actor n background

Posted:
Wed Jun 13, 2012 5:11 pm
by skydereign
I mentioned in the comment that rand(2) when set equal to an int will equal only 0 or 1. rand(2) will never return 2, it may though return 1.9999. That being said if you set an int equal to any floating point number, C will just remove the floating point.
- Code: Select all
int a = 1.5; // a will be equal 1
int b = 2.9; // b will equal 2
dzuncoi wrote:btw, where can i get these kinds of code ?
You search the forums, and by doing so learn a bit C and gE.
Re: actor n background

Posted:
Wed Jun 13, 2012 5:15 pm
by dzuncoi
i got it

thank you for helping me so far

Re: actor n background

Posted:
Mon Jun 18, 2012 1:28 pm
by dzuncoi
Hello guys, im going to finish my small game

i still have some troubles and need your help. That's about physical response between player and the ground, it seems not real, like this:
http://www.youtube.com/watch?v=rz9pqEBpWIM&feature=youtu.be (i dont know how to post a video)
In this video, i want the player not able to reach the block but he still does

i just use state method, so is there any others way to make it real ?
Re: actor n background

Posted:
Mon Jun 18, 2012 5:01 pm
by skydereign
You need to have a collision event for the left and right sides of the ground actor. I recommend using the non-stick method for that collision.
- Code: Select all
double yvel = yvelocity; // save yvelocity's value
//put the PhysicalResponse here
yvelocity = yvel; // set yvelocity back to yvel
Re: actor n background

Posted:
Tue Jun 19, 2012 4:16 am
by dzuncoi
I used that already

you sent me this page
http://game-editor.com/State_Method in page 1 and i follow this tutorial, maybe there are somethings wrong in my code, let me check it
Re: actor n background

Posted:
Tue Jun 19, 2012 4:59 am
by skydereign
Ah, yes. That example has the proper code, and I believe looks pretty realistic (there is a ged I made somewhere that goes well with that tutorial). Perhaps you didn't set the collision event to repeat (which would allow the player to pass through the wall).
Re: actor n background

Posted:
Tue Jun 19, 2012 5:10 am
by dzuncoi
I've just delete and write all the codes again and they seem better

there are maybe some mistakes somewhere

Re: actor n background

Posted:
Mon Jun 25, 2012 5:07 pm
by dzuncoi
hello guys, i need some help, this is my problem :
http://www.youtube.com/watch?v=YMCtH5jFmhY My player animation is so strange when i press right or left key, can you help me to fix it?