Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! Using the c language and I need help with a particular problem. I have sprite that has to move from stationary to walking speed

Hello! Using the c language and I need help with a particular problem.

I have sprite that has to move from stationary to walking speed (0.5) when a key is pressed. Either 'a' or 'd' for left and right respectivly. All this is encpsulated in a single function called onestep that plays one step of the game. Now, the problem arises when I have to make the character run i.e change the speed to 1 from the current walking speed of 0.5 when the same key is pressed again. So far i've got something like this for walking right: if ( key == d ){ walk }, however I dont' know how to deal with a second key press once the sprite is walking. Heres what I have so far, I know its wrong, but am I at least on the right track?

I.e

set global variable speed = 0;

for walking: if ( key == d) { walk and set speed = 1}

for running: if ( key == d && speed = 1){ run and set speed = 2}

doesn't work because the program goes right into the 'run' if statement regardless once d is pressed.... Any help would be appreaciated! Thanks!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago

Question

How would you assess the value of an approach like this?

Answered: 1 week ago