Cov txheej txheem:
- Kauj Ruam 1: Nyeem Duab
- Kauj Ruam 2: Duab ntsig txog kev ua haujlwm
- Kauj Ruam 3: Tso Music, Ua Si & Nres
- Kauj Ruam 4: Tswj Lub Suab Nkauj
- Kauj Ruam 5: Ua Si Video thiab Nres
- Kauj Ruam 6: Kev Tswj Yees Duab Ceev
- Kauj Ruam 7: Ua Txheej Txheem Txheej Txheem
- Kauj Ruam 8: Piv Piv Txwv-Music Keyboard
- Kauj Ruam 9: Piv Piv Txwv-Music Palette 1
- Kauj Ruam 10: Piv Piv Txwv-Music Palette 2 (Hloov Kho Tshiab)
- Kauj Ruam 11: Txheeb Ze Txog Lub Suab & Kev Tswj Video
- Kauj Ruam 12: Nyeem txheeb ze:
- Kauj Ruam 13: Qhov Chaw
Video: Nthuav Tawm Cov Txheej Txheem Qhia Ntawv rau Tus Tsim-Media Loading thiab Txheej Txheem: 13 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Kev ua haujlwm tuaj yeem thauj ntau cov ntaub ntawv sab nraud, ntawm uas muaj peb hom uas nquag siv. Lawv yog cov duab, suab thiab yees duab sib cais.
Hauv tshooj lus no, peb yuav tham txog yuav ua li cas thauj lub suab thiab yees duab kom ntxaws, ua ke nrog cov xwm txheej. Thaum kawg, koj tuaj yeem tsim koj tus kheej cov keyboard lossis suab paj nruag.
Kauj Ruam 1: Nyeem Duab
Ua ntej peb pib, cia saib rov qab rau txoj hauv kev ntawm kev thau duab.
Kauj Ruam 2: Duab ntsig txog kev ua haujlwm
Ua ntej peb siv cov haujlwm no, peb yuav tsum tsim cov khoom siv duab los ntawm PImage. Tom qab ntawd peb tuaj yeem siv cov haujlwm no txhawm rau txheeb xyuas txhua yam khoom duab.
Tsis txhob hnov qab khaws koj cov duab los rau hauv cov ntaub ntawv ua ntej ua haujlwm koj li program.
Kauj Ruam 3: Tso Music, Ua Si & Nres
Hauv cov hauv qab no, peb pib ua ntu zus qhia kev hu nkauj rau koj. Zoo heev rau kev thau duab, koj yuav tsum tshaj tawm lub suab khoom thaum pib. Koj tuaj yeem xa mus rau qhov piv txwv hauv qab no los ntawm cov qauv sau ntawv tiag.
Txoj Cai Piv Txwv (10-1):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.sound.*;
SoundFile suab;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (255);
suab = SoundFile tshiab (qhov no, "1.mp3");
}
void kos () {
}
void keyPressed () {
// Ua suab
yog (qhov tseem ceeb == 'p') {
suab.play ();
}
Nres suab
yog (qhov tseem ceeb == 's') {
suab.stop ();
}
} [/cceN_cpp]
Kev npaj:
Ua nws tus kheej tsis nqa lub tsev qiv ntawv suab. Koj yuav tsum rub nws los ntawm koj tus kheej. Yog li, ua ntej sau koj cov cai, koj yuav zoo dua los npaj cov hauv qab no.
Ntxiv tsev qiv ntawv rau Kev Ua. Nov yog kev coj ua ib txwm muaj. Xaiv los ntawm cov ntawv qhia zaub mov bar rau "Tool"- "Add Tool", thiab tom qab ntawd hloov mus rau "Libraries". Sau cov lus tseem ceeb ntawm lub tsev qiv ntawv rau hauv kab tshawb nrhiav kom koj tuaj yeem rub tawm thiab teeb tsa ncaj qha.
Txawm li cas los xij, yog tias peb siv txoj haujlwm no hauv peb lub tebchaws (hauv Suav Teb), peb tsis tuaj yeem rub nws los ntawm kev txuas lub vev xaib ncaj qha. Peb yuav tsum pib VPN. Txawm hais tias peb pib nws, yuav muaj xwm txheej tsis xwm yeem. Yog li koj yuav tsum ua siab ntev sim nws ob peb zaug. Nov yog txoj hauv kev yooj yim tshaj plaws ntawm kev thauj khoom. Yog tias koj tsis tuaj yeem teeb tsa, koj yuav tsum rub tawm los ntawm lub vev xaib raug cai los ntawm phau ntawv. (https://processing.org/reference/libraries/) Vim tias phau ntawv teeb tsa txheej txheem yog qhov nyuaj heev, peb yuav tham ntxiv hauv lwm tshooj.
Txoj Cai Exaplain:
Lub tsev qiv ntawv suab tuaj yeem ua haujlwm tau zoo tom qab kev npaj ua tiav. Cope cov cai saum toj no, nyem RUN, tom qab ntawd nws yuav ua haujlwm. Nias tus yuam sij "P" los ua suab paj nruag, "S" kom nres suab paj nruag.
Yog tias nws tau siv rau txoj haujlwm, peb yuav tsum thauj nws ua ntej. Thaum pib, peb yuav tsum ntxiv kab lus "ntshuam ua cov suab.*". "ntshuam" yog lo lus tseem ceeb, lub ntsiab lus thauj khoom. Ntxiv lub tsev qiv ntawv lub npe tom qab "ntshuam", tom qab ntawd nws yuav thauj lub tsev qiv ntawv. Tus Tsov tus tw feem ntau ua raws lub cim ntawm "*", yog li nws yuav thauj tag nrho cov tsev qiv ntawv cuam tshuam nrog chav kawm rau hauv qhov haujlwm yam tsis tas yuav ntxiv lawv ib leeg los ntawm ib tus.
Hauv kab lus thib ob, "SoundFile suab;" tau tshaj tawm cov khoom siv suab. SoundFile zoo ib yam li PImage.
Hauv kev teeb tsa kev ua haujlwm, "suab = SoundFile tshiab (qhov no," 1.mp3 ");" yog siv los tsim cov khoom thiab txhais nws txoj kev nyeem. Ntawm no peb yeej tau pib siv lub tswv yim tshiab Class. Tam sim no peb tsis tham txog nws tob. Peb tsuas yog xav paub nws yog txoj hauv kev sau thiab qhov ntsuas kawg yog txhawm rau sau qhov chaw nyob ntawm cov nkauj.
Ntawm cov keyPressed () cov xwm txheej, "sound.play ()" thiab "sound.stop ()" kuj ua haujlwm raws li kev ua si thiab nres. "." nyob hauv nruab nrab qhia txog tus tswv cuab ua haujlwm uas ua si thiab tso tseg rau cov khoom suab. Peb tuaj yeem suav cov tswv cuab ua haujlwm raws li cov haujlwm muaj nyob hauv cov khoom. Nws yog tus tswv ntawm qhov khoom no, uas tau hais ua ntej. Tom qab ntawd, thaum peb xav tau los ua ntau yam khoom siv suab, peb tsuas yog ntxiv ".play ()" tom qab lub npe sib txawv txheeb ze.
Cov peev txheej suab yuav tsum khaws cia rau hauv cov ntaub ntawv cov ntaub ntawv hauv tib daim ntawv teev npe ntawm sketchfile (nrog pde txuas ntxiv). Yog tias tsis muaj, koj tuaj yeem tsim ib qho.
Tsis txhob hnov qab sau qhov kos duab. Txawm hais tias koj tsis tau kos cov duab, nws yog qhov tsim nyog los ua suab paj nruag kom tiav.
Cov txheej txheem saum toj no zoo li nyuaj heev, tab sis koj yuav tsum ntxiv ob peb kab lus ntawm cov cai nkaus xwb, tom qab ntawd koj tuaj yeem paub ua haujlwm. Nws yooj yim heev.
Kev ua haujlwm txhawb nqa cov suab sib xws xws li mp3, wav, ogg, thiab lwm yam.
Kauj Ruam 4: Tswj Lub Suab Nkauj
Cov piv txwv hauv qab no yuav pib dhau los ua qhov nthuav. Kev ua haujlwm tau muab qee qhov haujlwm uas tuaj yeem tswj suab paj nruag ua si nrawm. Nyob rau tib lub sijhawm, lub suab nrov yuav hloov nrog suab paj nruag ua si nrawm. Thaum peb siv nas los tswj, nws yuav tsim cov txiaj ntsig zoo heev.
Yees duab lub vev xaib:
Txoj Cai Piv Txwv (10-2):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.sound.*;
SoundFile suab;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (255);
suab = SoundFile tshiab (qhov no, "1.mp3");
}
void kos () {
ntab ceev = mouseX/(ntab) dav * 3;
suab.rate (ceev);
ntab vol = mouseY/(ntab) qhov siab * 4;
sound.amp (ntim);
}
void keyPressed () {
// Ua suab
yog (qhov tseem ceeb == 'p') {
suab.play ();
}
Nres suab
yog (qhov tseem ceeb == 's') {
suab.stop ();
}
} [/cceN_cpp]
Cai piav qhia:
Muaj nuj nqi.rate () tswj lub suab ua si nrawm. Tus nqi hauv kab lus txiav txim qhov nrawm thiab qeeb ntawm kev ua si nrawm. Thaum tus nqi yog 1, kev ua si nrawm yog qhov qub. Thaum nws dhau 1, tom qab ntawd ua kom nrawm dua; thaum nws qis dua 1, tom qab ntawd ua kom qeeb.
Muaj nuj nqi.amp () tswj lub suab ntim. Tus nqi hauv kab lus txiav txim siab tus nqi ntim. Thaum nws yog 1, tus nqi ntim tau ib txwm muaj. Thaum nws dhau 1, tom qab ntawd nce ntim; thaum nws qis dua 1, tom qab ntawd txo ntim.
Ntawm no peb tau tsim ob qhov kev hloov pauv hauv cheeb tsam hauv zos thiab qhov vol raws li qhov yuav tsum tau ntim rau hauv. Yog li txoj kab ke sib dhos ntawm tus nas yuav hloov lub suab paj nruag, thiab txoj haujlwm sib koom ua ke yuav hloov lub suab paj nruag.
Kauj Ruam 5: Ua Si Video thiab Nres
Hauv Kev Ua Haujlwm, rub tawm cov vis dis aus zoo ib yam li tso suab. Koj yuav tsum rub lub tsev qiv ntawv yees duab ua ntej. (https://processing.org/reference/libraries/video/index.html)
Txoj Cai Piv Txwv (10-3):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.video.*;
Movie mov;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (0);
mov = New Movie (this, "1.mov");
}
void movieEvent (Movie yeeb yam) {
mov.read (); mov.
}
void kos () {
duab (mov, 0, 0, 640, 360);
}
void keyPressed () {
yog (qhov tseem ceeb == 'p') {
mov.play ();
}
yog (qhov tseem ceeb == 's') {
mov.stop ();
}
yog (qhov tseem ceeb == 'd') {
mov.pause ();
}
} [/cceN_cpp]
Screenshot yees duab:
Cai piav qhia:
Thawj kab lus "import processing.video.*;" Yog siv los thauj cov tsev qiv ntawv yees duab.
Kab lus thib ob "Movie mov;" yog siv los tshaj tawm cov vis dis aus. Ntawm nws, txoj haujlwm ntawm "Movie" zoo ib yam li PImage.
Hauv kev teeb tsa kev ua haujlwm, cov nyhuv ntawm "mov = New Movie (qhov no," 1.mov ");" yog los tsim cov khoom thiab txheeb xyuas nws txoj kev nyeem. Qhov ntsuas kawg yuav tsum tau sau nrog qhov chaw nyob ntawm cov vis dis aus.
Behine teeb tsa, movieEvent sawv cev rau kev tshwm sim video. Nws yog siv los hloov kho thiab nyeem cov ntaub ntawv video. "mov.read ()" hauv qhov xwm txheej txhais tau tias nyeem.
Tsuas yog tso saib cov duab, cov duab ua haujlwm tuaj yeem tso tawm video ib yam. Peb tuaj yeem suav cov vis dis aus ua duab zoo. Thawj qhov ntsuas, peb sau lub npe sib txawv ntawm cov khoom yeeb yaj kiab. Qhov thib ob thiab thib peb tsis yog kab rov tav thiab ntsug sib koom kos los ntawm video. Qhov thib plaub thiab tsib tsib qhov kev txiav txim siab qhov ntev thiab dav ntawm cov vis dis aus.
Muaj nuj nqi.play () txhais tau tias ua si. Muaj nuj nqi.stop () txhais tau tias nres, thiab nws yuav rov pib dua cov vis dis aus. Muaj nuj nqi.pause () txhais tau tias ncua. Nws yuav cuam tshuam kev ua si tam sim no, uas yuav txuas ntxiv mus txog thaum ua haujlwm.play () raug caw tuaj koom.
Kauj Ruam 6: Kev Tswj Yees Duab Ceev
Txoj Cai Piv Txwv (10-4):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.video.*;
Movie mov;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (0);
mov = New Movie (this, "transit.mov");
}
void movieEvent (Movie yeeb yam) {
mov.read ();
}
void kos () {
duab (mov, 0, 0, dav, qhov siab);
ntab newSpeed = mouseX/(ntab) dav * 4;
mov.speed (newSpeed);
}
void keyPressed () {
yog (qhov tseem ceeb == 'p') {
mov.play ();
}
yog (qhov tseem ceeb == 's') {
mov.stop ();
}
yog (qhov tseem ceeb == 'd') {
mov.pause ();
}
}
[/cceN_cpp]
Cai piav qhia:
Muaj nuj nqi.speed () tuaj yeem siv los tswj cov vis dis aus ua si nrawm. Thaum tus nqi ntsuas yog 1, kev ua si nrawm yog qhov qub. Thaum tus nqi dhau 1, tom qab ntawd ua kom nrawm dua; thaum nws qis dua 1, tom qab ntawd deccelerate.
Vim tias peb tau tsim lub nroog hloov pauv tshiab newSpeed thiab xa nws mus rau hauv kev ua haujlwm setSpeed (), kev sib koom tes ntawm nas yuav cuam tshuam cov vis dis aus ua si nrawm.
Raws li ntau qhov piv txwv txog kev yees duab, koj tuaj yeem xa mus rau Lub Tsev Qiv Ntawv - Yees duab hauv rooj plaub.
Kauj Ruam 7: Ua Txheej Txheem Txheej Txheem
Yav dhau los, peb tau tshaj tawm keyPressed () kev tshwm sim nkaus xwb. Nws yuav tshwm sim tom qab nias lub keyboard. Hauv qab no, peb yuav qhia lwm yam xwm txheej hauv Kev Ua Haujlwm rau koj.
Kev siv ntawm cov xwm txheej saum toj no zoo ib yam li keyPressed. Lawv tsis muaj ib theem zuj zus hauv kev sau cov cai. Hauv lwm lo lus, tsis hais yam xwm txheej twg koj tau tso ua ntej lossis tom qab teeb tsa kev ua haujlwm, koj tau txais txiaj ntsig zoo ib yam. Qhov kev txiav txim tiav tsuas yog cuam tshuam nrog qhov tshwm sim ntawm qhov xwm txheej nws tus kheej. Tsuas yog tias qhov xwm txheej tau ntsib, tom qab ntawd nws yuav ua. Cov xwm txheej saum toj no yog txhua yam yooj yim to taub. Koj tsuas yog yuav tsum ua qhov kev sim me me, tom qab ntawd koj tuaj yeem nkag siab lawv cov kev siv.
Txheej Txheem Flow
Peb tuaj yeem siv tus piv txwv los paub qhov kev txiav txim ua tiav ntawm cov xwm txheej.
Txoj Cai Piv Txwv (10-5):
[cceN_cpp ntsiab lus = "kaj ntug"] tsis muaj teeb tsa teeb tsa () {
tus nqiRate (2);
println (1);
}
void kos () {
println (2);
}
void mousePressed () {
println (3);
}
void mouseMoved () {
println (4);
}
void nasReleased () {
println (5);
}
void keyPressed () {
println (6);
}
void keyReleased () {
println (7);
} [/cceN_cpp]
Cai piav qhia:
Hauv kev teeb tsa kev ua haujlwm, ua haujlwm frameRate () tau teeb tsa kev ua haujlwm nrawm ntawm qhov haujlwm kom yog 2 ntas ib ob. Kev txo qis tus nqi tuaj yeem pab peb soj ntsuam qhov tso tawm hauv lub console yog tias cov xwm txheej tshwm sim yuav raug txhuam tam sim los ntawm cov ntaub ntawv tshiab mus rau tom qab.
Sim txav koj nas, nyem nas, tso nas thiab soj ntsuam qhov tshwm sim. Tau paub txog qhov kev ua tiav kev txiav txim los ntawm println.
Dab tsi tsim nyog tau txais kev mloog yog kos lub zog tsis tuaj yeem sau rau lwm qhov xwm txheej tshwj tsis yog kos duab, lossis nws tsis tuaj yeem tso saib. Yog tias peb xav tswj hwm qhov zais thiab tso saib cov duab nraaj los ntawm cov xwm txheej zoo li keyPressed, peb yuav txiav txim siab los tsim bool kuj sib txawv raws li qhov nruab nrab.
Cov xwm txheej yuav ua nyob rau hauv kev txiav txim. Tsuas yog tom qab tag nrho cov cai hauv qhov xwm txheej tam sim no tau ua tiav, nws yuav ua tus lej hauv qhov xwm txheej tom ntej.
Kauj Ruam 8: Piv Piv Txwv-Music Keyboard
Ua ke nrog cov xwm txheej tshiab uas tau tuav, peb tuaj yeem ntxiv kev sib cuam tshuam tshiab rau peb txoj haujlwm. Ntxiv mus, tsuas yog nrog ob peb feeb, peb tuaj yeem sib piv cov keyboard suab paj nruag yooj yim.
Yees duab lub vev xaib:
Txoj Cai Piv Txwv (10-6):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.sound.*;
SoundFile suab 1, suab 2, suab 3, suab 4, suab 5;
boolean key1, key2, key3, key4, key5;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (255);
noStroke ();
sound1 = tshiab SoundFile (qhov no, "do.wav");
sound2 = SoundFile tshiab (qhov no, "re.wav");
sound3 = SoundFile tshiab (qhov no, "mi.wav");
sound4 = tshiab SoundFile (qhov no, "fa.wav");
suab 5 = SoundFile tshiab (qhov no, "so.wav");
}
void kos () {
keeb kwm yav dhau (255, 214, 79);
rectMode (CENTER);
ntab w = dav * 0.1;
ntab h = qhov siab * 0.8;
yog (key1) {
sau (255);
lwm yam {
sau (238, 145, 117);
}
rect (dav/6, qhov siab/2, w, h);
yog (key2) {
sau (255);
lwm yam {
sau (246, 96, 100);
}
rect (dav/6 * 2, qhov siab/2, w, h);
yog tias (key3) {
sau (255);
lwm yam {
sau (214, 86, 113);
}
rect (dav/6 * 3, qhov siab/2, w, h);
yog tias (key4) {
sau (255);
lwm yam {
sau (124, 60, 131);
}
rect (dav/6 * 4, qhov siab/2, w, h);
yog tias (key5) {
sau (255);
lwm yam {
sau (107, 27, 157);
}
rect (dav/6 * 5, qhov siab/2, w, h);
}
void keyPressed () {
yog (qhov tseem ceeb == 'a') {
sound1.play ();
key1 = tseeb;
}
yog (qhov tseem ceeb == 's') {
suab2.play ();
key2 = tseeb;
}
yog (qhov tseem ceeb == 'd') {
sound3.play ();
key3 = tseeb;
}
yog (qhov tseem ceeb == 'f') {
sound4.play ();
key4 = tseeb;
}
yog (qhov tseem ceeb == 'g') {
suab5.play ();
key5 = tseeb;
}
}
void keyReleased () {
yog (qhov tseem ceeb == 'a') {
key1 = tsis tseeb;
}
yog (qhov tseem ceeb == 's') {
key2 = tsis tseeb;
}
yog (qhov tseem ceeb == 'd') {
key3 = tsis tseeb;
}
yog (qhov tseem ceeb == 'f') {
key4 = tsis tseeb;
}
yog (qhov tseem ceeb == 'g') {
key5 = tsis tseeb;
}
} [/cceN_cpp]
Cai piav qhia:
Peb yuav tsum tsim ntau yam khoom siv suab los nyeem cov ntaub ntawv suab sib txheeb kom ua suab sib txawv thaum cov yuam sij sib txawv tshwm sim.
Ntawm no peb siv qhov xwm txheej tshiabReleased (). Lub luag haujlwm ntawm qhov kev tshwm sim no yog rov kho cov xim keyboard rau nws cov xim qub. Thaum tso tus yuam sij, nws yuav tshwm sim.
5 tus nqi boolean tshaj tawm hauv lub taub hau tau siv los txheeb xyuas qhov xwm txheej ntawm tus yuam sij.
Kauj Ruam 9: Piv Piv Txwv-Music Palette 1
Dhau li ntawm cov xwm txheej keyboard, nas tshwm sim yog qhov zoo uas peb yuav tsum siv nws hloov pauv. Cov piv txwv hauv qab no yog rau peb los tsim lub suab paj nruag, ntawm qhov uas peb tau siv ob lub nas cuam tshuam txog cov xwm txheej.
Yees duab lub vev xaib:
Txoj Cai Piv Txwv (10-7):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.sound.*;
SoundFile suab 1, suab 2, suab 3, suab 4, suab 5;
boolean isDragging;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (255, 214, 79);
noStroke ();
sound1 = tshiab SoundFile (qhov no, "do.wav");
sound2 = SoundFile tshiab (qhov no, "re.wav");
sound3 = SoundFile tshiab (qhov no, "mi.wav");
sound4 = SoundFile tshiab (qhov no, "fa.wav");
suab 5 = SoundFile tshiab (qhov no, "so.wav");
}
void kos () {
yog (isDragging) {
sau (107, 27, 157, 100);
ellipse (mouseX, mouseY, 16, 16);
}
}
void mouseDragged () {
isDragging = muaj tseeb;
yog (mouseX> 100 && mouseX <105) {
sound1.play ();
}
yog (mouseX> 200 && mouseX <205) {
suab2.play ();
}
yog (mouseX> 300 && mouseX <305) {
sound3.play ();
}
yog (mouseX> 400 && mouseX <405) {
sound4.play ();
}
yog (mouseX> 500 && mouseX <505) {
suab5.play ();
}
}
void nasReleased () {
isDragging = tsis tseeb;
} [/cceN_cpp]
Cai piav qhia:
Peb cia siab tias tsuas yog thaum peb tau nias tus nas thiab rub nws, peb tuaj yeem kos duab. Yog li peb yuav tsum tsim kom muaj qhov sib txawv boolean isDragging kom tau txais cov xwm txheej tam sim no.
Thaum rub tus nas, isDragging dhau los ua qhov muaj txiaj ntsig thiaj li kos duab ua haujlwm hauv Draw yuav ua tiav. Nws yuav tawm ib qho cim ntawm qhov screen. Thaum peb tso tus nas, isDragging dhau los ua qhov tsis raug. Yog li cov duab kos hauv kev kos duab yuav nres qhov ua tiav.
Peb tau tsim ob peb qhov xwm txheej tshwm sim hauv nas rub qhov tshwm sim. Piv txwv li, thaum kab rov tav ua haujlwm ntawm nas yog ntawm 100 thiab 105 pixels, suab paj nruag yuav raug ntaus ua ke. Qhov no ua rau lub vijtsam tsim ob peb txoj hlua tsis pom. Tsuas yog tias nas dhau los ntawm qee qhov chaw, nws yuav ua rau cov nkauj sib txheeb.
Kauj Ruam 10: Piv Piv Txwv-Music Palette 2 (Hloov Kho Tshiab)
Cov txiaj ntsig ntawm qhov piv txwv saum toj no twb zoo txaus lawm. Tab sis yog peb ua tib zoo saib, peb yuav pom ntau yam teeb meem. Piv txwv li, thaum tus nas txav nrawm heev, nws yuav tawm ib puag ncig ntawm lub vijtsam txhua zaus nws txav mus. Nws tsis yog txoj kab ncaj ncaj. Lub caij no, nws tseem ua rau qee cov suab paj nruag xau. Thaum thaum tus nas txav qeeb heev, dhau los ntawm txoj haujlwm thaum txoj haujlwm sib dhos yog ntawm 100 thiab 105, nws yuav tshaj tawm suab paj nruag rau ntau zaus nyob rau lub sijhawm luv luv, uas ua rau koj zoo li raug daig. Txhua qhov teeb meem no, peb tuaj yeem daws nws los ntawm qhov piv txwv hauv qab no.
Koj tuaj yeem saib cov vis dis aus hauv qhov link hauv qab no:
v.qq.com/x/page/w03226o4y4l.html
Txoj Cai Piv Txwv (10-8):
[cceN_cpp ntsiab lus = "kaj ntug"] ntshuam ua tiav.sound.*;
SoundFile suab 1, suab 2, suab 3, suab 4, suab 5;
boolean isDragging;
void teeb tsa () {
loj (640, 360);
keeb kwm yav dhau (255, 214, 79);
noStroke ();
sound1 = tshiab SoundFile (qhov no, "do.wav");
sound2 = SoundFile tshiab (qhov no, "re.wav");
sound3 = SoundFile tshiab (qhov no, "mi.wav");
sound4 = SoundFile tshiab (qhov no, "fa.wav");
suab 5 = SoundFile tshiab (qhov no, "so.wav");
}
void kos () {
yog (isDragging) {
mob stroke (107, 27, 157, 100);
Qhov hnyav (10);
kab (mouseX, mouseY, pmouseX, pmouseY);
}
}
void mouseDragged () {
isDragging = muaj tseeb;
yog ((mouseX - 100) * (pmouseX - 100) <0) {
sound1.play ();
}
yog ((mouseX - 200) * (pmouseX - 200) <0) {
suab2.play ();
}
yog ((mouseX - 300) * (pmouseX - 300) <0) {
sound3.play ();
}
yog ((mouseX - 400) * (pmouseX - 400) <0) {
sound4.play ();
}
yog ((mouseX - 500) * (pmouseX - 500) <0) {
suab5.play ();
}
}
void mouseReleased () {
isDragging = tsis tseeb;
} [/cceN_cpp]
Cai piav qhia:
Ntawm no peb tau siv ob qhov sib txawv pmouseX thiab pmouseY nqa hauv Kev Ua Haujlwm nws tus kheej. Lawv zoo ib yam li mouseX thiab mouseY tab sis qhov lawv tau txais yog kev sib koom ntawm nas hauv tus ncej tas los.
Hauv Kev kos duab, peb tau siv kab kab () los hloov qhov kev ua haujlwm qub ellipse (). Qhov no ua rau kev sib koom ua ke ntawm cov thav duab kawg txuas nrog kev ua haujlwm ntawm cov thav duab tam sim no ncaj qha. Yog li peb tuaj yeem kos kab ncaj ncaj los yog nkhaus.
Hauv qhov kev tshwm sim mouseDragged, peb tau tsim qhov xwm txheej tshiab tshwm sim. Los ntawm kev txiav txim siab seb qhov kev sib koom tes ntawm lub thav duab kawg thiab lub thav duab tam sim no nyob rau hauv ib sab kom paub seb puas muaj kev sib koom tes hla. Siv qhov xwm txheej no ua piv txwv: "yog ((mouseX - 100) * (pmouseX - 100) <0)". Ntawm nws, los ntawm qhov txiaj ntsig zoo thiab tsis zoo tshwm sim los ntawm "mouseX - 100", peb tuaj yeem paub tias mouseX nyob ntawm sab xis lossis sab laug ntawm kab rov tav coodinate 100. Zoo ib yam li "pmouseX - 100". Yog li ntawd, thaum ob lub ntsiab lus nyob rau sab xub ntiag thiab sab nraub qaum tsis nyob hauv ib sab, qhov zoo sib npaug tsis zoo, nws yuav tau txais tus lej tshiab tsis zoo. Yog li qhov ua tiav kev mob siab.
Qhov saum toj no yog cov lus piav qhia yooj yim, uas tau siv qee qhov kev ua lej zauv-Ob qhov tsis zoo sib npaug yuav tsim qhov zoo. Koj tseem tuaj yeem faib nws ua ob qhov xwm txheej los sib tham sib cais. Txawm li cas los xij, nws nyuaj dua los sau cov lus txiav txim. Cov kev txiav txim siab "yog ((mouseX = 100) || (mouseX> 100 && pmouseX <= 100))" yog sib npaug rau kev txiav txim siab ntawm cov cai.
Kauj Ruam 11: Txheeb Ze Txog Lub Suab & Kev Tswj Video
Cov haujlwm uas tau hais los saum no yog txaus rau cov xwm txheej siv dav. Yog tias koj xav khawb nws tob, ntawm no kuv tau sau qee qhov haujlwm sib xws rau lub suab thiab yees duab rau koj. Koj tuaj yeem tshawb xyuas nws cov kev siv raws li koj tus kheej xav tau.
Yog xav paub ntxiv, koj tuaj yeem xa mus rau cov ntaub ntawv los ntawm lub vev xaib raug cai.
Suab (https://processing.org/reference/libraries/sound/index.html)
Video (https://processing.org/reference/libraries/video/index.html)
Kab lus no los ntawm tus tsim qauv Wenzy.
Kauj Ruam 12: Nyeem txheeb ze:
Nthuav qhia txoj hauv kev rau tus tsim qauv-Ua Thawj Kov
Nthuav qhia txoj hauv kev rau tus tsim qauv – Tsim Koj Thawj Qhov Txheej Txheem
Nthuav qhia txoj hauv kev rau tus tsim qauv-Tau txais koj daim duab ua haujlwm (Tshooj Ib)
Nthuav qhia txoj hauv kev rau tus tsim qauv-Tau txais koj daim duab ua haujlwm (Ntu Ob)
Nthuav nthuav Cov Txheej Txheem Qhia rau Tus Tsim Qauv – Txoj Haujlwm Txheej Txheem Tswj- Loop Nqe Lus
Nthuav qhia txoj hauv kev rau tus tsim qauv-Txoj Cai Tswj Xyuas Txheej Txheem-Cov Lus Qhia Txog Tus Mob (Ntu Ib)
Nthuav qhia txoj hauv kev rau tus tsim qauv-Kev Tswj Xyuas Txheej Txheem-Cov Lus Qhia Txog Tus Mob (Ntu Ob)
Nthuav qhia txoj hauv kev qhia rau tus tsim qauv-Kev ua haujlwm tshwj xeeb thiab Fractal Recursion
Nthuav qhia txoj hauv kev qhia rau tus tsim qauv-Kev ua haujlwm tshwj xeeb thiab Fractal Recursion
Nthuav Cov Txheej Txheem Qhia Ntawv rau Tus Tsim-Xim Tswj
Kauj Ruam 13: Qhov Chaw
Kab lus no yog los ntawm:
Yog tias koj muaj lus nug, koj tuaj yeem tiv toj : [email protected].
Pom zoo:
Nthuav Tawm Cov Txheej Txheem Qhia Ntawv rau Tus Tsim Qauv-Tswj Xim: 10 Kauj Ruam
Nthuav Tawm Cov Txheej Txheem Txheej Txheem rau Tus Tsim-Xim Tswj: Hauv tshooj dhau los, peb tau tham ntau ntxiv txog yuav siv tus lej li cas los ua qhov hloov pauv ntawm cov ntsiab lus paub txog xim. Hauv tshooj no, peb tab tom tshawb fawb txog qhov kev paub no tob dua
Xim Txheej Txheem Txheej Txheem: Arduino Raws Li Txheej Txheem Nrog Ob Txoj Siv: 8 Kauj Ruam
Xim Txheej Txheem Txheej Txheem: Arduino Raws Li Txheej Txheem Nrog Ob Txoj Siv: Kev thauj mus los thiab/lossis ntim khoom ntawm cov khoom thiab cov khoom hauv thaj chaw ua haujlwm tau ua tiav siv cov kab ua siv siv txoj siv thauj khoom. Cov menyuam no pab txav cov khoom ntawm ib kis mus rau lwm qhov nrog qhov nrawm. Qee qhov kev ua lossis kev qhia paub ua haujlwm yuav yog
Cov Txheej Txheem Hluav Taws Xob rau FTC Robots - Cov Txheej Txheem thiab Cov Lus Qhia: 4 Cov Kauj Ruam
Muaj Cov Txheej Txheem Hluav Taws Xob rau FTC Neeg Hlau - Cov Txheej Txheem thiab Cov Lus Qhia: Ntau pawg FTC tso siab rau cov txheej txheem thaiv yooj yim thiab cov cuab yeej los teeb tsa hluav taws xob rau lawv cov neeg hlau. Txawm li cas los xij, cov txheej txheem yooj yim no thiab cov ntaub ntawv yuav tsis txaus rau cov kab hluav taws xob xav tau ntau dua. Txawm hais tias koj pab neeg tab tom siv kev paub ntau dua
D4E1: Kev nyeem ntawv-cuab yeej 2.0 (Txheej Txheem Txheej Txheem Txheej Txheem): 9 Cov Kauj Ruam (nrog Duab)
D4E1: Kev nyeem ntawv-cuab yeej 2.0 (Txheej Txheem Txheej Txheem Txheej Txheem): Cov ntaub ntawv:-Ob tus tub ntxhais kawm Muaj cov khoom lag luam tsim qauv hauv Kortrijk (Belgium) tuaj nrog cov cuab yeej nyeem ntawv no. Peb pib raws qhov tsim qauv uas twb muaj lawm thiab tau txhim kho nws mus rau lwm qhov kev tsim. Kev nyeem ntawv-cuab yeej thaum xub thawj tau raug txhim kho rau cli & nte
Nthuav nthuav Cov Txheej Txheem Qhia rau Tus Tsim Qauv-Txheej Txheem Txheej Txheem Tswj- Loop Nqe Lus: 8 Kauj Ruam
Nthuav nthuav Cov Txheej Txheem Qhia rau Tus Tsim-Txheej Txheem Txheej Txheem- Loop Nqe Lus: Cov Txheej Txheem Txheej Txheem- Loop Nqe Lus Los ntawm tshooj no, koj yuav ntsib nrog qhov tseem ceeb thiab muaj zog paub txog-Loop Nqe Lus. Ua ntej nyeem tshooj no, yog tias koj xav kos 10,000 lub voj voos hauv txoj haujlwm, koj tsuas tuaj yeem ua nrog lub suab