Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » HELP!!!! CPU programming
- Trex1010
- Scratcher
8 posts
HELP!!!! CPU programming
I need some help on how to program a character that the computer controls.
Any help?
Thanks, Trex1010
Any help?
Thanks, Trex1010
- amylaser
- Scratcher
500+ posts
HELP!!!! CPU programming
You need to give us more details - there are literally an infinite number of ways you could go about this, depending on what you want your AI to do.
First off, how do you want the CPU-controlled character to act?
Is there an objective it needs to accomplish, in opposition to the human player?
Or does it just perform automated tasks?
It would be great if you could also share the relevant project with us and post a link so we can look at your scripts and give you better answers.
First off, how do you want the CPU-controlled character to act?
Is there an objective it needs to accomplish, in opposition to the human player?
Or does it just perform automated tasks?
It would be great if you could also share the relevant project with us and post a link so we can look at your scripts and give you better answers.
Last edited by amylaser (Oct. 19, 2016 13:29:38)
- ghernkhoo
- Scratcher
36 posts
HELP!!!! CPU programming
when green flag clickedthese are scripts for maze
if <key [right arrow v] pressed?> then
move (5) steps
end
if <key [left arrow v] pressed?> then
move (-5) steps
end
if <key [up arrow v] pressed?> then
change y by (5)
end
if <key [down arrow v] pressed?> then
change y by (-5 )
end
Last edited by ghernkhoo (Oct. 19, 2016 04:51:18)
This is a signature
Not manually typed
When i post on the forum this shows below what i type
thank you
Roses are red,
Violets are blue.
Omae wa mou
Shindeiru
- Trex1010
- Scratcher
8 posts
HELP!!!! CPU programming
You need to give us more details - there are literally an infinite number of ways you could go about this, depending on what you want your AI to do.
First off, how do you want the CPU-controlled character to act?
Is there an objective it needs to accomplish, in opposition to the human player?
Or does it just perform automated tasks?
It would be great if you could also share the relevant project with us and post a link so we can look at your scripts and give you better answers.
Yes, sorry I wasn't clear on that. I am making a game where you are battling the CPU on level ground.
The CPU will try to attack the player, and try to dodge the players attacks.
Thanks!
- amylaser
- Scratcher
500+ posts
HELP!!!! CPU programming
Okay, I'd still urge you to share the project though - we need to know how your current scripts look before we can suggest ways to code the CPU.
List of some more things we'd need to know about:
1) The scripts that determine how the CPU moves. Does it move in bursts of speed? Constant speed? Can it jump, or only move left and right? Can it teleport? Can it fly?
2) The scripts that determine how the CPU attacks. Does it have to be standing near the Player? Can it shoot at the Player from afar? Does it summon falling objects from the sky? Can it aim at the Player, or does it shoot in random directions? By how much does it decrease the Player's health?
3) The scripts that determine how the Player attacks. Does it attack the same way the CPU does? Does it deal damage or knockback?
4) The scripts that determine how the game starts/ends. Does the CPU change its behavior when it reaches a certain level of health? Or what happens to the CPU when either it or the Player “dies”?
So yeah. Please share your project, or show some specific pieces of code you're having trouble with.
List of some more things we'd need to know about:
1) The scripts that determine how the CPU moves. Does it move in bursts of speed? Constant speed? Can it jump, or only move left and right? Can it teleport? Can it fly?
2) The scripts that determine how the CPU attacks. Does it have to be standing near the Player? Can it shoot at the Player from afar? Does it summon falling objects from the sky? Can it aim at the Player, or does it shoot in random directions? By how much does it decrease the Player's health?
3) The scripts that determine how the Player attacks. Does it attack the same way the CPU does? Does it deal damage or knockback?
4) The scripts that determine how the game starts/ends. Does the CPU change its behavior when it reaches a certain level of health? Or what happens to the CPU when either it or the Player “dies”?
So yeah. Please share your project, or show some specific pieces of code you're having trouble with.
Last edited by amylaser (Oct. 22, 2016 01:36:33)
- Sports_crazy43
- Scratcher
5 posts
HELP!!!! CPU programming
this is my project I want him to run around https://scratch.mit.edu/projects/552370380/
- Sports_crazy43
- Scratcher
5 posts
HELP!!!! CPU programming
https://scratch.mit.edu/projects/552370380/constant speed cant do anything elese he needs to score more points than the player this is my project I want him to run around
Last edited by Sports_crazy43 (July 30, 2021 14:56:12)
- The_Imaginarium
- Scratcher
1000+ posts
HELP!!!! CPU programming
Please create your own topic instead of posting on someone else's.https://scratch.mit.edu/projects/552370380/constant speed cant do anything elese he needs to score more points than the player this is my project I want him to run around
- orangetheory
- Scratcher
500+ posts
HELP!!!! CPU programming
Make a variable called Attacking?
So the variable changes whenever the player attacks.
Put this in the player that isn't the CPU, or the player that you are supposed to control.
Then in the CPU, put
Hope this helped!
(attacking?)
So the variable changes whenever the player attacks.
Put this in the player that isn't the CPU, or the player that you are supposed to control.
when green flag clicked
forever
if <key [space v] pressed?> then
attacking code here::pen
set [attacking? v] to [y] // y is yes
else
set [attacking? v] to [n] // n is no
end
end
Then in the CPU, put
when green flag clicked
forever
if <touching [character v] ?> then
if <(attacking?) = [y]> then
set [Dodge v] to (pick random (No v) to (Yes v))
end
end
end
Then in same sprite, put
when green flag clicked
forever
if <(Dodge) = [yes]> then
Do Nothing, or put your own code here
else
Getting hurt code here
end
end
Hope this helped!
-Frisbee- -Cricket--Basketball--Forums--Mapping--Coding--Trigonometry master--Mathematics King--Future Prime Minister--Intro-Maker-
I know HTML/CSS, and JavaScript, and with these coding skills I have made some decent projects! Test them out below!
~Archery~Cops + Robbers~
Want an intro, outro, music, effects, or more? Check out the intro shop!
The forum helpers, a place where we help people in the forums
- lorick42
- Scratcher
19 posts
HELP!!!! CPU programming
do you wan't a profject like this?: https://scratch.mit.edu/projects/543948839/You need to give us more details - there are literally an infinite number of ways you could go about this, depending on what you want your AI to do.
First off, how do you want the CPU-controlled character to act?
Is there an objective it needs to accomplish, in opposition to the human player?
Or does it just perform automated tasks?
It would be great if you could also share the relevant project with us and post a link so we can look at your scripts and give you better answers.
Yes, sorry I wasn't clear on that. I am making a game where you are battling the CPU on level ground.
The CPU will try to attack the player, and try to dodge the players attacks.
Thanks!
- orangetheory
- Scratcher
500+ posts
HELP!!!! CPU programming
also, this is fairly old and should be closed by now.
-Frisbee- -Cricket--Basketball--Forums--Mapping--Coding--Trigonometry master--Mathematics King--Future Prime Minister--Intro-Maker-
I know HTML/CSS, and JavaScript, and with these coding skills I have made some decent projects! Test them out below!
~Archery~Cops + Robbers~
Want an intro, outro, music, effects, or more? Check out the intro shop!
The forum helpers, a place where we help people in the forums
- Discussion Forums
- » Help with Scripts
- » HELP!!!! CPU programming