admin admin
EXP : 534 เงินมาเฟีย : 3218 ค่าพิชิตศัตรู : 0 ชื่อเสียง : 38 ฉายา : ผู้รักซาวาดะ
ผู้รักโซลอีทเตอร์
ผู้รัก code gass
วันที่สมัคร : 22/08/2009 อายุ : 24 ที่อยู่ : บ้านไง สถานะ : admin จิ
กิจกรรม ประกาศ: ทุกคนตั้งใจโพสเข้าหล่ะแต่อย่าปั้มนะ
| เรื่อง: < บทเรียนที่ 8 ทำตัวละครลับและตัวละครสำหรับคอม > Wed Apr 14, 2010 3:14 pm | |
| เนื่องมาจากการทำตัวละครลับ/ซ่อนตัวละคร/ตัวละครของคอมโดยเฉพาะ มักมี 2 แบบที่ใช้กัน ได้แก่ 1. จากคนเขียนสครีนแพ็คที่เขากำหนดค่าต่างๆมาให้อยู่แล้ ว อันนี้จะง่ายหน่อยเพราะแค่จับวางตามที่เขากำหนดมาก็เ ป็นอันใช้ได้ตามต้องการครับ ( อันนี้คงไม่ต้องสอน)
2. หาตำแหน่งหรือจัดตำแหน่งตัวละคร เพื่อทำตัวละครลับหรือตัวละครคอมเอาเอง ตัวอย่างนะครับ
การเตรียมพร้อม สมมติว่า จากไฟล์ system.def ( อ่านรายละเอียดการเพิ่มแถวข้างบนนะ) rows = 5 ; 5 แถว columns = 10 ; แต่ละแถวมี 10 ช่อง wrapping = 1 ; ให้เซ็ตเป็น 1 ครับ เพื่อทำให้เลือกวนรอบได้ showemptyboxes = 0 ; เซ็ตเป็น0เพื่อไม่ให้มีช่องกรอบขึ้นมาครับถ้าทำเป็น1 จะมีกรอบออกมาเต็มจอเลยครับ moveoveremptyboxes = 0 ;เซ็ตเป็น 0 เพื่อกันไม่ให้เข้าไปถึงในส่วนช่องว่างครับ
สมมติว่า ในหน้าเลือกตัวละคร มีพื้นที่ว่างสามารถใส่ตัวละครในแนวนอนได้ 10 ช่อง และแนวตั้งได้ 10 ช่อง แต่จากไฟล์ system.def เราเซ็ตไว้เป็น แนวนอน 5 แนวตั้ง 10 ใช่ไหมครับ เราต้องการซ่อนตัวละครให้เราทำแบบนี้นะครับ
กรณีแนวนอน แก้ค่า row ให้มากกว่าพื้นที่ว่างตามแนวนอน ( ในนี้ คือ 10 ) สมมติให้ row = 13 ( ซ่อนตัวละคร 3 ตัว) ตามภาพนะ 1 2 3 4 5 6 7 8 9 10 | 11 12 13 ; หลัง | คือ ตัวละครที่ถูกซ่อน แล้วเราต้องไปแก้แถวใน select.def เองนะครับ จาก แถวแรก มี 5 ช่อง ; row1 char1 here char2 here char3 here char4 here char5 here
ก็แก้เป็น 13 ช่องแทนนะซึ่ง จะได้ ;row1 char1 here char2 here char3 here char4 here char5 here char6 here char7 here char8 here char9 here char10 here ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char1 หรือเราจะใส่ตัวที่เราต้องการแค่ 6 ตัวก็ได้ (แล้วแต่ความชอบ) เพราะเซ็ตให้มันผ่านช่องว่างไม่ได้แล้ว ดังตัวอย่าง ;row1 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3
กรณีแนวตั้ง แก้ค่า columns ให้มากกว่าจำนวนช่องว่างของฉาก ( ในนี้ คือ 10 ) สมมติให้ columns = 13 ( ซ่อนตัวละคร 3 แถว ) ซึ่งจะต่อจากแถวที่ 10 นะครับ ตัวอย่างนะครับ ;row1 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 ;row2 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3
. . . ..... ....... .......... ; สมมติว่าถึงแถว 10 แล้วนะ ;row10 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 ;row11 xxxxxxxxxxx xxxxxxxxxxx secret char3 here secret char4 here secret char5 here secret char6 here secret char7 here secret char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 ;row12 xxxxxxxxxxx xxxxxxxxxxx secret char3 here secret char4 here secret char5 here secret char6 here secret char7 here secret char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 ;row13 นี้จะวนไปต่อกับ แถวแรกนะครับ xxxxxxxxxxx xxxxxxxxxxx secret char3 here secret char4 here secret char5 here secret char6 here secret char7 here secret char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3
เป็นอันเสร็จการทำตัวละครลับครับ จะพบว่าในแถวที่ 11 - 13 จะถูกซ่อนเอาไว้ครับ
แก้ไขล่าสุดโดย admin เมื่อ Wed Apr 14, 2010 3:15 pm, ทั้งหมด 1 ครั้ง | |
|
admin admin
EXP : 534 เงินมาเฟีย : 3218 ค่าพิชิตศัตรู : 0 ชื่อเสียง : 38 ฉายา : ผู้รักซาวาดะ
ผู้รักโซลอีทเตอร์
ผู้รัก code gass
วันที่สมัคร : 22/08/2009 อายุ : 24 ที่อยู่ : บ้านไง สถานะ : admin จิ
กิจกรรม ประกาศ: ทุกคนตั้งใจโพสเข้าหล่ะแต่อย่าปั้มนะ
| เรื่อง: Re: < บทเรียนที่ 8 ทำตัวละครลับและตัวละครสำหรับคอม > Wed Apr 14, 2010 3:14 pm | |
| อ้าว แล้วการทำตัวละครเฉพาะของคอมทำยังไงล่ะ ง่ายๆครับ วิธีเดิมแต่พลิกแพลงเล็กน้อยครับ ก่อนอื่น เราลองคิดดูสิว่า การทำตัวละครให้คอมเล่นนั้นทำไมเราถึงเล่นไม่ได้ คำตอบก็คือ ว่าเราไม่สามารถเลือกตัวละครมาได้นั่นเอง หมายความว่าเราจะมาสร้างแถวสำหรับตัวละครสำหรับคอมคร ับ
ผมขอใช้ข้อมูลเดิมจากการสร้างช่องสำหรับตัวละครลับนะ ครับ จำได้ใช้ไหมว่า เราเซ็ตให้ row = 13 , columns = 13 แต่ตอนนี้ผมอยากเพิ่มตัวละคร CPU มาสัก 4 ตัว ให้ทำดังนี้นะครับ เซ็ตให้ row = 14 , columns = 17 ( อาจใช้ค่าแบบอื่นก็ได้ครับ แต่ผมขอสาธิตแบบนี้นะ) โดยเรามาลองเพิ่มตัวละคร CPU ในแถวที่ 14 กัน
ตัวอย่างนะครับ ;row1 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข ;row2 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข . . . ..... ....... .......... ; สมมติว่าถึงแถว 10 แล้วนะ ;row10 xxxxxxxxxxx xxxxxxxxxxx char3 here char4 here char5 here char6 here char7 here char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข ;row11 xxxxxxxxxxx xxxxxxxxxxx secret char3 here secret char4 here secret char5 here secret char6 here secret char7 here secret char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข ;row12 xxxxxxxxxxx xxxxxxxxxxx secret char3 here secret char4 here secret char5 here secret char6 here secret char7 here secret char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข ;row13 นี้จะวนไปต่อกับ แถวแรกนะครับ xxxxxxxxxxx xxxxxxxxxxx secret char3 here secret char4 here secret char5 here secret char6 here secret char7 here secret char8 here xxxxxxxxxxx xxxxxxxxxxx ;-------------------- secret char11 here secret char12 here secret char13 here ; ตัวนี้จะวนไปต่อกับ char3 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข ;row14 Don't edit anything here1 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here2 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here3 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here4 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here5 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here6 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here7 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here8 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here9 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here10 ; บริเวณนี้ห้ามแก้ไข ;-------------------- Don't edit anything here11 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here12 ; บริเวณนี้ห้ามแก้ไข Don't edit anything here13 ; บริเวณนี้ห้ามแก้ไข Char for CPU ONLY1 ; ช่องสำหรับเพิ่มตัวละครสำหรับคอมครับ Char for CPU ONLY2 ; ช่องสำหรับเพิ่มตัวละครสำหรับคอมครับ Char for CPU ONLY3 ; ช่องสำหรับเพิ่มตัวละครสำหรับคอมครับ Char for CPU ONLY4 ; ช่องสำหรับเพิ่มตัวละครสำหรับคอมครับ
จะพบว่าพื้นที่สำหรับตัวละครเฉพาะคอมฯ ได้ถูกสร้างขึ้นมาแล้ว ที่สร้างขึ้นมาได้เพราะว่า ในแถวที่ 14 ในหลักที่ 14 - 17 ไม่มีการเชื่อมโยงกับ แถวที่ 14 ในหลัก 1-13 เลย และกรณีเดียวกัน ในแถวที่ 14 ในหลักที่ 14 - 17 ไม่มีการเชื่อมโยงตัวละครกับแถวอื่นๆเลย ทำให้เราไม่สามารถเลือกใช้ตัวละครในแถวที่ 14 หลักที่ 14 - 17 ได้นั่นเอง
สรุป การทำตัวละครลับแบบนี้จะเป็นการใช้ประโยชน์ของพื้นที ่ว่างของฉากที่จำกัดมาช่วยในการบดบังตัวละครที่จะซ่อ นเอาไว้และ ตัวละครสำหรับคอมฯเป็นการใช้พื้นที่หรือบริเวณที่ผู้ เล่นไม่สามารถเข้าถึงได้นั่นเองครับ | |
|